#include <bits/stdc++.h>
using namespace std;
static const long long INF = 1010000000000000017LL;
static const double eps = 1e-12;
static const double pi = 3.14159265358979323846;
static const long long dx[4] = {1, -1, 0, 0};
static const long long dy[4] = {0, 0, 1, -1};
static const long long ddx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
static const long long ddy[8] = {0, 0, 1, -1, 1, -1, 1, -1};
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
long long N;
long long A[200005];
signed main() {
  cin >> N;
  for (long long i = 0; i < N; ++i) cin >> A[i];
  long long fumi = 0;
  for (long long i = 0; i < N - 1; ++i) {
    if (A[i] < A[i + 1]) chmax(fumi, A[i + 1] - A[i]);
  }
  cout << fumi << endl;
}
