#include <iostream>
using namespace std;

int prices[(int)1e7];
int n;

int main()
{
  cin >> n;
  for(int i=0;i<n;i++) cin >> prices[i];
  int res = 0;

  for (int i = 0; i < n - 1; i++) 
  for (int j = i + 1; j < n; j++)
    res = max(res, prices[j] - prices[i]);

  cout << res << endl;
}



