# Question Name:HUNGER GAMES

``````#include<bits/stdc++.h>
using namespace std;
int main()
{
int N,ans=0,a;
vector<int>v;
cin>>N;
for(int i=0;i<N;i++)
{
cin>>a;
v.push_back(a);
}
sort(v.begin(),v.end());
for(int i=0;i<N-2;i++)
{
ans=max(ans,v[i+2]-v[i]);
}
cout<<ans;
}``````
• Problem Description
You have reached the final level of Hunger Games and as usual a tough task awaits you. You have a circular dining table and N hungery animals.You need to place them on the table.Each animal has a hunger value.

You can place the animals in any order on the circular table.Once you place them you need to calculate the Danger value of your arrangement.

The danger value of the arrangement is the maximum difference of hunger values of all the adjacent seated animals.You need to keep this danger value as low as possible.

Input:
The first line contains N integers.
The second line contains the hunger values of N animals.

Output:
Print the minimum possible danger value.

Constraints:

3<=N<=1000
1<=Hunger Value<=1000
• Test Case 1
Input (stdin)4
5 10 6 8
Expected Output4
• Test Case 2
Input (stdin)42
468 335 501 170 725 479 359 963 465 706 146 282 828 962 492 996 943 828 437 392 605 903 154 293 383 422 717 719 896 448 727 772 539 870 913 668 300 36 895 704 812 323
Expected Output129