class Main
{
	public static void main( String[] args )
	{
		java.util.Scanner sc = new java.util.Scanner( System.in );
		int n = sc.nextInt();
		int max = -1000000000, min = sc.nextInt();
		int in;
		for( int ct = 1 ; ct < n ; ct++ ){
			in = sc.nextInt();
			if( in-min > max )max = in-min;
			if( in < min )min = in;
		}
		System.out.printf( "%d\n" , max );
	}
} class Main
{
	public static void main( String[] args )
	{
		java.util.Scanner sc = new java.util.Scanner( System.in );
		int n = sc.nextInt();
		int max = -1000000000, min = sc.nextInt();
		int in;
		for( int ct = 1 ; ct < n ; ct++ ){
			in = sc.nextInt();
			if( in-min > max )max = in-min;
			if( in < min )min = in;
		}
		System.out.printf( "%d\n" , max );
	}
} Main public static void main( String[] args )
	{
		java.util.Scanner sc = new java.util.Scanner( System.in );
		int n = sc.nextInt();
		int max = -1000000000, min = sc.nextInt();
		int in;
		for( int ct = 1 ; ct < n ; ct++ ){
			in = sc.nextInt();
			if( in-min > max )max = in-min;
			if( in < min )min = in;
		}
		System.out.printf( "%d\n" , max );
	} main {
		java.util.Scanner sc = new java.util.Scanner( System.in );
		int n = sc.nextInt();
		int max = -1000000000, min = sc.nextInt();
		int in;
		for( int ct = 1 ; ct < n ; ct++ ){
			in = sc.nextInt();
			if( in-min > max )max = in-min;
			if( in < min )min = in;
		}
		System.out.printf( "%d\n" , max );
	} java.util.Scanner sc = new java.util.Scanner( System.in ); sc new java.util.Scanner( System.in ) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int max = -1000000000 max -1000000000 1000000000 min = sc.nextInt(); min sc.nextInt() sc.nextInt sc int in; in for( int ct = 1 ; ct < n ; ct++ ){
			in = sc.nextInt();
			if( in-min > max )max = in-min;
			if( in < min )min = in;
		} int ct = 1 ; int ct = 1 ; ct 1 ct < n ct n ct++ ct++ ct {
			in = sc.nextInt();
			if( in-min > max )max = in-min;
			if( in < min )min = in;
		} {
			in = sc.nextInt();
			if( in-min > max )max = in-min;
			if( in < min )min = in;
		} in = sc.nextInt() in sc.nextInt() sc.nextInt sc if( in-min > max )max = in-min; in-min > max in-min in min max max = in-min max in-min in min if( in < min )min = in; in < min in min min = in min in System.out.printf( "%d\n" , max ) System.out.printf System.out System System.out "%d\n" max String[] args args
class Main
{
	public static void main( String[] args )
	{
		java.util.Scanner sc = new java.util.Scanner( System.in );
		int n = sc.nextInt();
		int max = -1000000000, min = sc.nextInt();
		int in;
		for( int ct = 1 ; ct < n ; ct++ ){
			in = sc.nextInt();
			if( in-min > max )max = in-min;
			if( in < min )min = in;
		}
		System.out.printf( "%d\n" , max );
	}
}