#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int M = -2100000000;
  int m = 2100000000;
  for (int i = 0; i < n; i++){
    int R;
    cin >> R;
    M = max(M, R - m);
    m = min(m, R);
  }
  cout << M << endl;
}
