#include <bits/stdc++.h>
# define endl            '\n'
# define clr(x,a)        memset(x,a,sizeof(x))
# define vi              vector<int>
# define all(a)          a.begin(), a.end()
# define deb(x)          cout<<#x<<"=="<<x<<endl;
# define pb              push_back
# define sc              scanf
# define pr              printf
# define tc              int testcase; cin>>testcase; while(testcase--)
# define rev(s)          reverse(s.begin(),s.end())
# define linija          cout<<"___________\n";
using namespace std;
typedef long long ll;
const int mxN=10005;
int n, k, a[mxN], uzimanje[21], sol;

int main(){
   cin>>n>>k;
   for(int i=1; i<=n; i++) cin>>a[i];
   cout<<max(a[n]-a[1], a[1]-a[n])<<endl;

   return 0;
}