import std.stdio;
import std.algorithm;

void main(){
    int n,res,m;
    int[] R = new int[200000];
    readf("%d\n",&n);
    for(int i=0;i<n;i++){
	readf("%d\n",&R[i]);
    }

    m = 2000000000;
    res = -2000000000;
    for(int i=0;i<n-1;i++){
	m = min(m,R[i]);
	res = max(R[i+1] - m,res);
    }
    writeln(res);
}
	