import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		//????§??????°
		int num;
		
		//?????§???
		int max;
		
		//?¨??????¨?????°
		int maxValue = -2000000000;
		int minValue;
		
		
		num=Integer.parseInt(bf.readLine());
		int tmp[]=new int[num];
		
		for(int i=0;i<num;i++){
			tmp[i]=Integer.parseInt(bf.readLine());
		}
		
		minValue=tmp[0];
		for(int i=1;i<num;i++){
			maxValue= maxValue > tmp[i]-minValue ? maxValue:tmp[i]-minValue;
			minValue = tmp[i] > minValue ? minValue:tmp[i];
		}
		
		System.out.println(maxValue);
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		//????§??????°
		int num;
		
		//?????§???
		int max;
		
		//?¨??????¨?????°
		int maxValue = -2000000000;
		int minValue;
		
		
		num=Integer.parseInt(bf.readLine());
		int tmp[]=new int[num];
		
		for(int i=0;i<num;i++){
			tmp[i]=Integer.parseInt(bf.readLine());
		}
		
		minValue=tmp[0];
		for(int i=1;i<num;i++){
			maxValue= maxValue > tmp[i]-minValue ? maxValue:tmp[i]-minValue;
			minValue = tmp[i] > minValue ? minValue:tmp[i];
		}
		
		System.out.println(maxValue);
	}

} Main public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		//????§??????°
		int num;
		
		//?????§???
		int max;
		
		//?¨??????¨?????°
		int maxValue = -2000000000;
		int minValue;
		
		
		num=Integer.parseInt(bf.readLine());
		int tmp[]=new int[num];
		
		for(int i=0;i<num;i++){
			tmp[i]=Integer.parseInt(bf.readLine());
		}
		
		minValue=tmp[0];
		for(int i=1;i<num;i++){
			maxValue= maxValue > tmp[i]-minValue ? maxValue:tmp[i]-minValue;
			minValue = tmp[i] > minValue ? minValue:tmp[i];
		}
		
		System.out.println(maxValue);
	} main {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		//????§??????°
		int num;
		
		//?????§???
		int max;
		
		//?¨??????¨?????°
		int maxValue = -2000000000;
		int minValue;
		
		
		num=Integer.parseInt(bf.readLine());
		int tmp[]=new int[num];
		
		for(int i=0;i<num;i++){
			tmp[i]=Integer.parseInt(bf.readLine());
		}
		
		minValue=tmp[0];
		for(int i=1;i<num;i++){
			maxValue= maxValue > tmp[i]-minValue ? maxValue:tmp[i]-minValue;
			minValue = tmp[i] > minValue ? minValue:tmp[i];
		}
		
		System.out.println(maxValue);
	} BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); bf new BufferedReader(new InputStreamReader(System.in)) String line; line int num; num int max; max int maxValue = -2000000000; maxValue -2000000000 2000000000 int minValue; minValue num=Integer.parseInt(bf.readLine()) num Integer.parseInt(bf.readLine()) Integer.parseInt Integer bf.readLine() bf.readLine bf int tmp[]=new int[num]; tmp new int[num] num for(int i=0;i<num;i++){
			tmp[i]=Integer.parseInt(bf.readLine());
		} int i=0; int i=0; i 0 i<num i num i++ i++ i {
			tmp[i]=Integer.parseInt(bf.readLine());
		} {
			tmp[i]=Integer.parseInt(bf.readLine());
		} tmp[i]=Integer.parseInt(bf.readLine()) tmp[i] tmp i Integer.parseInt(bf.readLine()) Integer.parseInt Integer bf.readLine() bf.readLine bf minValue=tmp[0] minValue tmp[0] tmp 0 for(int i=1;i<num;i++){
			maxValue= maxValue > tmp[i]-minValue ? maxValue:tmp[i]-minValue;
			minValue = tmp[i] > minValue ? minValue:tmp[i];
		} int i=1; int i=1; i 1 i<num i num i++ i++ i {
			maxValue= maxValue > tmp[i]-minValue ? maxValue:tmp[i]-minValue;
			minValue = tmp[i] > minValue ? minValue:tmp[i];
		} {
			maxValue= maxValue > tmp[i]-minValue ? maxValue:tmp[i]-minValue;
			minValue = tmp[i] > minValue ? minValue:tmp[i];
		} maxValue= maxValue > tmp[i]-minValue ? maxValue:tmp[i]-minValue maxValue maxValue > tmp[i]-minValue ? maxValue:tmp[i]-minValue maxValue > tmp[i]-minValue maxValue tmp[i]-minValue tmp[i] tmp i minValue maxValue tmp[i]-minValue tmp[i] tmp i minValue minValue = tmp[i] > minValue ? minValue:tmp[i] minValue tmp[i] > minValue ? minValue:tmp[i] tmp[i] > minValue tmp[i] tmp i minValue minValue tmp[i] tmp i System.out.println(maxValue) System.out.println System.out System System.out maxValue String[] args args public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		//????§??????°
		int num;
		
		//?????§???
		int max;
		
		//?¨??????¨?????°
		int maxValue = -2000000000;
		int minValue;
		
		
		num=Integer.parseInt(bf.readLine());
		int tmp[]=new int[num];
		
		for(int i=0;i<num;i++){
			tmp[i]=Integer.parseInt(bf.readLine());
		}
		
		minValue=tmp[0];
		for(int i=1;i<num;i++){
			maxValue= maxValue > tmp[i]-minValue ? maxValue:tmp[i]-minValue;
			minValue = tmp[i] > minValue ? minValue:tmp[i];
		}
		
		System.out.println(maxValue);
	}

} public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		//????§??????°
		int num;
		
		//?????§???
		int max;
		
		//?¨??????¨?????°
		int maxValue = -2000000000;
		int minValue;
		
		
		num=Integer.parseInt(bf.readLine());
		int tmp[]=new int[num];
		
		for(int i=0;i<num;i++){
			tmp[i]=Integer.parseInt(bf.readLine());
		}
		
		minValue=tmp[0];
		for(int i=1;i<num;i++){
			maxValue= maxValue > tmp[i]-minValue ? maxValue:tmp[i]-minValue;
			minValue = tmp[i] > minValue ? minValue:tmp[i];
		}
		
		System.out.println(maxValue);
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		//????§??????°
		int num;
		
		//?????§???
		int max;
		
		//?¨??????¨?????°
		int maxValue = -2000000000;
		int minValue;
		
		
		num=Integer.parseInt(bf.readLine());
		int tmp[]=new int[num];
		
		for(int i=0;i<num;i++){
			tmp[i]=Integer.parseInt(bf.readLine());
		}
		
		minValue=tmp[0];
		for(int i=1;i<num;i++){
			maxValue= maxValue > tmp[i]-minValue ? maxValue:tmp[i]-minValue;
			minValue = tmp[i] > minValue ? minValue:tmp[i];
		}
		
		System.out.println(maxValue);
	}

}