#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
int main() {
  long long n = 0;
  cin >> n;
  long long max = 0;
  int *arr = new int[n];
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  for (int i = 1; i < n; i++) {
    for (int j = i - 1; j > -1; j--) {
      if (arr[i] - arr[i - 1] > max) {
        max = arr[i] - arr[i - 1];
      }
    }
  }
  cout << max;
}
