import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		
		Scanner sc= new Scanner (System.in);
		int n=Integer.parseInt(sc.nextLine());
		int num;
		int ori=2000000001;
		int answer=-2000000000;
		for(int i=0;i<n;i++){
			num = Integer.parseInt(sc.nextLine());
			if(i>0 && answer<num-ori){
				answer=num-ori;
			}
			if(ori>num){
				ori=num;
			}
		}
		System.out.println(answer);
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args){
		
		Scanner sc= new Scanner (System.in);
		int n=Integer.parseInt(sc.nextLine());
		int num;
		int ori=2000000001;
		int answer=-2000000000;
		for(int i=0;i<n;i++){
			num = Integer.parseInt(sc.nextLine());
			if(i>0 && answer<num-ori){
				answer=num-ori;
			}
			if(ori>num){
				ori=num;
			}
		}
		System.out.println(answer);
	}
} Main public static void main(String[] args){
		
		Scanner sc= new Scanner (System.in);
		int n=Integer.parseInt(sc.nextLine());
		int num;
		int ori=2000000001;
		int answer=-2000000000;
		for(int i=0;i<n;i++){
			num = Integer.parseInt(sc.nextLine());
			if(i>0 && answer<num-ori){
				answer=num-ori;
			}
			if(ori>num){
				ori=num;
			}
		}
		System.out.println(answer);
	} main {
		
		Scanner sc= new Scanner (System.in);
		int n=Integer.parseInt(sc.nextLine());
		int num;
		int ori=2000000001;
		int answer=-2000000000;
		for(int i=0;i<n;i++){
			num = Integer.parseInt(sc.nextLine());
			if(i>0 && answer<num-ori){
				answer=num-ori;
			}
			if(ori>num){
				ori=num;
			}
		}
		System.out.println(answer);
	} Scanner sc= new Scanner (System.in); sc new Scanner (System.in) int n=Integer.parseInt(sc.nextLine()); n Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc int num; num int ori=2000000001; ori 2000000001 int answer=-2000000000; answer -2000000000 2000000000 for(int i=0;i<n;i++){
			num = Integer.parseInt(sc.nextLine());
			if(i>0 && answer<num-ori){
				answer=num-ori;
			}
			if(ori>num){
				ori=num;
			}
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			num = Integer.parseInt(sc.nextLine());
			if(i>0 && answer<num-ori){
				answer=num-ori;
			}
			if(ori>num){
				ori=num;
			}
		} {
			num = Integer.parseInt(sc.nextLine());
			if(i>0 && answer<num-ori){
				answer=num-ori;
			}
			if(ori>num){
				ori=num;
			}
		} num = Integer.parseInt(sc.nextLine()) num Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc if(i>0 && answer<num-ori){
				answer=num-ori;
			} i>0 && answer<num-ori i>0 i 0 answer<num-ori answer num-ori num ori {
				answer=num-ori;
			} answer=num-ori answer num-ori num ori if(ori>num){
				ori=num;
			} ori>num ori num {
				ori=num;
			} ori=num ori num System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main{
	public static void main(String[] args){
		
		Scanner sc= new Scanner (System.in);
		int n=Integer.parseInt(sc.nextLine());
		int num;
		int ori=2000000001;
		int answer=-2000000000;
		for(int i=0;i<n;i++){
			num = Integer.parseInt(sc.nextLine());
			if(i>0 && answer<num-ori){
				answer=num-ori;
			}
			if(ori>num){
				ori=num;
			}
		}
		System.out.println(answer);
	}
} public class Main{
	public static void main(String[] args){
		
		Scanner sc= new Scanner (System.in);
		int n=Integer.parseInt(sc.nextLine());
		int num;
		int ori=2000000001;
		int answer=-2000000000;
		for(int i=0;i<n;i++){
			num = Integer.parseInt(sc.nextLine());
			if(i>0 && answer<num-ori){
				answer=num-ori;
			}
			if(ori>num){
				ori=num;
			}
		}
		System.out.println(answer);
	}
} Main
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		
		Scanner sc= new Scanner (System.in);
		int n=Integer.parseInt(sc.nextLine());
		int num;
		int ori=2000000001;
		int answer=-2000000000;
		for(int i=0;i<n;i++){
			num = Integer.parseInt(sc.nextLine());
			if(i>0 && answer<num-ori){
				answer=num-ori;
			}
			if(ori>num){
				ori=num;
			}
		}
		System.out.println(answer);
	}
}
