#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, s;
  cin >> n;
  int a[n];
  vector<int> v;
  s = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n - 1; i++) {
    if (a[i] <= a[i + 1]) {
      s = a[i + 1] - a[i];
    } else {
      v.push_back(s);
      s = 0;
    }
  }
  v.push_back(s);
  sort(v.begin(), v.end());
  cout << v[v.size() - 1];
}
