import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int num = scanner.nextInt();	//要素数
		
		gcd_profits(num, scanner);
		
		scanner.close();
	}
	
	public static void gcd_profits(int num , Scanner scanner) {
		int sub;
		int min;
		int count = 0;
		int profits = 0;
		int cur;

		min = (int)Math.pow(10, 9);
		profits = (int)Math.pow(10, 9) * -1;
		
		  while (count < num) {
		  	cur = scanner.nextInt();	//価格
		  	
		  	if(count != 0){
			  	
			  	//差分を出していく
			  	sub = cur - min;
			  	
			  	if( cur <= min ) {
			  		min = cur;
			  	}
			  	
			  	//最小か最大か調べる
			  	if( sub > profits ){
			  		profits = sub;
			  	}
		  	}else{
		  		min = cur;
		  	}
		  	
		  	count ++;
		  }
		  System.out.println(profits);
		}
}

 import java.util.Scanner; Scanner java.util class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int num = scanner.nextInt();	//要素数
		
		gcd_profits(num, scanner);
		
		scanner.close();
	}
	
	public static void gcd_profits(int num , Scanner scanner) {
		int sub;
		int min;
		int count = 0;
		int profits = 0;
		int cur;

		min = (int)Math.pow(10, 9);
		profits = (int)Math.pow(10, 9) * -1;
		
		  while (count < num) {
		  	cur = scanner.nextInt();	//価格
		  	
		  	if(count != 0){
			  	
			  	//差分を出していく
			  	sub = cur - min;
			  	
			  	if( cur <= min ) {
			  		min = cur;
			  	}
			  	
			  	//最小か最大か調べる
			  	if( sub > profits ){
			  		profits = sub;
			  	}
		  	}else{
		  		min = cur;
		  	}
		  	
		  	count ++;
		  }
		  System.out.println(profits);
		}
} Main public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int num = scanner.nextInt();	//要素数
		
		gcd_profits(num, scanner);
		
		scanner.close();
	} main {
		Scanner scanner = new Scanner(System.in);
		int num = scanner.nextInt();	//要素数
		
		gcd_profits(num, scanner);
		
		scanner.close();
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int num = scanner.nextInt(); num scanner.nextInt() scanner.nextInt scanner gcd_profits(num, scanner) gcd_profits num scanner scanner.close() scanner.close scanner String args[] args public static void gcd_profits(int num , Scanner scanner) {
		int sub;
		int min;
		int count = 0;
		int profits = 0;
		int cur;

		min = (int)Math.pow(10, 9);
		profits = (int)Math.pow(10, 9) * -1;
		
		  while (count < num) {
		  	cur = scanner.nextInt();	//価格
		  	
		  	if(count != 0){
			  	
			  	//差分を出していく
			  	sub = cur - min;
			  	
			  	if( cur <= min ) {
			  		min = cur;
			  	}
			  	
			  	//最小か最大か調べる
			  	if( sub > profits ){
			  		profits = sub;
			  	}
		  	}else{
		  		min = cur;
		  	}
		  	
		  	count ++;
		  }
		  System.out.println(profits);
		} gcd_profits {
		int sub;
		int min;
		int count = 0;
		int profits = 0;
		int cur;

		min = (int)Math.pow(10, 9);
		profits = (int)Math.pow(10, 9) * -1;
		
		  while (count < num) {
		  	cur = scanner.nextInt();	//価格
		  	
		  	if(count != 0){
			  	
			  	//差分を出していく
			  	sub = cur - min;
			  	
			  	if( cur <= min ) {
			  		min = cur;
			  	}
			  	
			  	//最小か最大か調べる
			  	if( sub > profits ){
			  		profits = sub;
			  	}
		  	}else{
		  		min = cur;
		  	}
		  	
		  	count ++;
		  }
		  System.out.println(profits);
		} int sub; sub int min; min int count = 0; count 0 int profits = 0; profits 0 int cur; cur min = (int)Math.pow(10, 9) min (int)Math.pow(10, 9) Math.pow Math 10 9 profits = (int)Math.pow(10, 9) * -1 profits (int)Math.pow(10, 9) * -1 (int)Math.pow(10, 9) Math.pow Math 10 9 -1 1 while (count < num) {
		  	cur = scanner.nextInt();	//価格
		  	
		  	if(count != 0){
			  	
			  	//差分を出していく
			  	sub = cur - min;
			  	
			  	if( cur <= min ) {
			  		min = cur;
			  	}
			  	
			  	//最小か最大か調べる
			  	if( sub > profits ){
			  		profits = sub;
			  	}
		  	}else{
		  		min = cur;
		  	}
		  	
		  	count ++;
		  } count < num count num {
		  	cur = scanner.nextInt();	//価格
		  	
		  	if(count != 0){
			  	
			  	//差分を出していく
			  	sub = cur - min;
			  	
			  	if( cur <= min ) {
			  		min = cur;
			  	}
			  	
			  	//最小か最大か調べる
			  	if( sub > profits ){
			  		profits = sub;
			  	}
		  	}else{
		  		min = cur;
		  	}
		  	
		  	count ++;
		  } cur = scanner.nextInt() cur scanner.nextInt() scanner.nextInt scanner if(count != 0){
			  	
			  	//差分を出していく
			  	sub = cur - min;
			  	
			  	if( cur <= min ) {
			  		min = cur;
			  	}
			  	
			  	//最小か最大か調べる
			  	if( sub > profits ){
			  		profits = sub;
			  	}
		  	}else{
		  		min = cur;
		  	} count != 0 count 0 {
			  	
			  	//差分を出していく
			  	sub = cur - min;
			  	
			  	if( cur <= min ) {
			  		min = cur;
			  	}
			  	
			  	//最小か最大か調べる
			  	if( sub > profits ){
			  		profits = sub;
			  	}
		  	} sub = cur - min sub cur - min cur min if( cur <= min ) {
			  		min = cur;
			  	} cur <= min cur min {
			  		min = cur;
			  	} min = cur min cur if( sub > profits ){
			  		profits = sub;
			  	} sub > profits sub profits {
			  		profits = sub;
			  	} profits = sub profits sub {
		  		min = cur;
		  	} min = cur min cur count ++ count System.out.println(profits) System.out.println System.out System System.out profits int num num Scanner scanner scanner
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int num = scanner.nextInt();	//要素数
		
		gcd_profits(num, scanner);
		
		scanner.close();
	}
	
	public static void gcd_profits(int num , Scanner scanner) {
		int sub;
		int min;
		int count = 0;
		int profits = 0;
		int cur;

		min = (int)Math.pow(10, 9);
		profits = (int)Math.pow(10, 9) * -1;
		
		  while (count < num) {
		  	cur = scanner.nextInt();	//価格
		  	
		  	if(count != 0){
			  	
			  	//差分を出していく
			  	sub = cur - min;
			  	
			  	if( cur <= min ) {
			  		min = cur;
			  	}
			  	
			  	//最小か最大か調べる
			  	if( sub > profits ){
			  		profits = sub;
			  	}
		  	}else{
		  		min = cur;
		  	}
		  	
		  	count ++;
		  }
		  System.out.println(profits);
		}
}


