#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int n, ans, minn = 0x3f3f3f3f, a[maxn], q[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (i == 1) continue;
    ans = max(ans, a[i] - min(a[i - 1], minn));
  }
  cout << ans;
}
