#include <bits/stdc++.h>
using namespace std;
void checkpoint1() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
bool comp(pair<long long, long long> &a, pair<long long, long long> &b) {
  if (a.first != b.first)
    return a.first < b.first;
  else {
    if (a.second > b.second)
      return b.second < a.second;
    else if (a.second < b.second)
      return a.second < b.second;
  }
  return a.first > b.first;
}
long long powe(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) {
      res *= a;
      res %= 1000000007;
    }
    a *= a;
    a %= 1000000007;
    b >>= 1;
  }
  return res;
}
int main() {
  checkpoint1();
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long ans = 0;
  for (long long i = 1; i < n; i++) ans = max(ans, a[i] - a[i - 1]);
  cout << ans;
  return 0;
}
