#include<bits/stdc++.h>
using namespace std;

int main(){
	int n, r, maxv = -2000000000;

	cin>>n>>r;

	int minv = r;

	for(int j = 1; j < n; j++){
		cin>>r;
		maxv = max(maxv, r - minv);
		minv = min(minv, r);
	}

	cout<<maxv<<endl;

	return 0;
}
