import java.util.*;
class Main{
	void aaaa(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int y;
		int min=2000000000;
		int x=-2000000000;
		for(int i=0;i<N;i++){
			y=sc.nextInt();
			if(y-min>x)x=y-min;
			if(min>y)min=y;
		}
		System.out.println(x);
	}
	public static void main(String[]arg){
		Main dn=new Main();
		dn.aaaa();
	}
} import java.util.*; util.* java class Main{
	void aaaa(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int y;
		int min=2000000000;
		int x=-2000000000;
		for(int i=0;i<N;i++){
			y=sc.nextInt();
			if(y-min>x)x=y-min;
			if(min>y)min=y;
		}
		System.out.println(x);
	}
	public static void main(String[]arg){
		Main dn=new Main();
		dn.aaaa();
	}
} Main void aaaa(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int y;
		int min=2000000000;
		int x=-2000000000;
		for(int i=0;i<N;i++){
			y=sc.nextInt();
			if(y-min>x)x=y-min;
			if(min>y)min=y;
		}
		System.out.println(x);
	} aaaa {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int y;
		int min=2000000000;
		int x=-2000000000;
		for(int i=0;i<N;i++){
			y=sc.nextInt();
			if(y-min>x)x=y-min;
			if(min>y)min=y;
		}
		System.out.println(x);
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int N=sc.nextInt(); N sc.nextInt() sc.nextInt sc int y; y int min=2000000000; min 2000000000 int x=-2000000000; x -2000000000 2000000000 for(int i=0;i<N;i++){
			y=sc.nextInt();
			if(y-min>x)x=y-min;
			if(min>y)min=y;
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			y=sc.nextInt();
			if(y-min>x)x=y-min;
			if(min>y)min=y;
		} {
			y=sc.nextInt();
			if(y-min>x)x=y-min;
			if(min>y)min=y;
		} y=sc.nextInt() y sc.nextInt() sc.nextInt sc if(y-min>x)x=y-min; y-min>x y-min y min x x=y-min x y-min y min if(min>y)min=y; min>y min y min=y min y System.out.println(x) System.out.println System.out System System.out x public static void main(String[]arg){
		Main dn=new Main();
		dn.aaaa();
	} main {
		Main dn=new Main();
		dn.aaaa();
	} Main dn=new Main(); dn new Main() dn.aaaa() dn.aaaa dn String[]arg arg
import java.util.*;
class Main{
	void aaaa(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int y;
		int min=2000000000;
		int x=-2000000000;
		for(int i=0;i<N;i++){
			y=sc.nextInt();
			if(y-min>x)x=y-min;
			if(min>y)min=y;
		}
		System.out.println(x);
	}
	public static void main(String[]arg){
		Main dn=new Main();
		dn.aaaa();
	}
}