#include <bits/stdc++.h>
using namespace std;
int n, a[2000005], _max = -100;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      _max = max(_max, a[j] - a[i]);
    }
  }
  printf("%d", _max);
  return 0;
}
