#include<iostream>
using namespace std;

int main(){
	int n,num[200000];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>num[i];
	}
	int maxn = -2000000000,minn = num[0];
	for(int j=1;j<n;j++){
		maxn = max(maxn,num[j]-minn);
		minn = min(minn,num[j]);
	}
		cout<<maxn<<endl;
	return 0;
}
