import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner number = new Scanner(System.in);
		int a  = number.nextInt();
		int[] b = new int[a];
		int c = 0,max = 0,min = 0;
		double d;

		for(int i = 0;i < a;i++) {
			b[i] = number.nextInt();
			
				
				
			if(i == 1 || max < b[i] - min) max = b[i] - min;
			if(i == 0 || b[i] < min) min = b[i];
			
			
		}
		System.out.println(max);
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner number = new Scanner(System.in);
		int a  = number.nextInt();
		int[] b = new int[a];
		int c = 0,max = 0,min = 0;
		double d;

		for(int i = 0;i < a;i++) {
			b[i] = number.nextInt();
			
				
				
			if(i == 1 || max < b[i] - min) max = b[i] - min;
			if(i == 0 || b[i] < min) min = b[i];
			
			
		}
		System.out.println(max);
	}
} Main public static void main(String[] args) {
		Scanner number = new Scanner(System.in);
		int a  = number.nextInt();
		int[] b = new int[a];
		int c = 0,max = 0,min = 0;
		double d;

		for(int i = 0;i < a;i++) {
			b[i] = number.nextInt();
			
				
				
			if(i == 1 || max < b[i] - min) max = b[i] - min;
			if(i == 0 || b[i] < min) min = b[i];
			
			
		}
		System.out.println(max);
	} main {
		Scanner number = new Scanner(System.in);
		int a  = number.nextInt();
		int[] b = new int[a];
		int c = 0,max = 0,min = 0;
		double d;

		for(int i = 0;i < a;i++) {
			b[i] = number.nextInt();
			
				
				
			if(i == 1 || max < b[i] - min) max = b[i] - min;
			if(i == 0 || b[i] < min) min = b[i];
			
			
		}
		System.out.println(max);
	} Scanner number = new Scanner(System.in); number new Scanner(System.in) int a  = number.nextInt(); a number.nextInt() number.nextInt number int[] b = new int[a]; b new int[a] a int c = 0 c 0 max = 0 max 0 min = 0; min 0 double d; d for(int i = 0;i < a;i++) {
			b[i] = number.nextInt();
			
				
				
			if(i == 1 || max < b[i] - min) max = b[i] - min;
			if(i == 0 || b[i] < min) min = b[i];
			
			
		} int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
			b[i] = number.nextInt();
			
				
				
			if(i == 1 || max < b[i] - min) max = b[i] - min;
			if(i == 0 || b[i] < min) min = b[i];
			
			
		} {
			b[i] = number.nextInt();
			
				
				
			if(i == 1 || max < b[i] - min) max = b[i] - min;
			if(i == 0 || b[i] < min) min = b[i];
			
			
		} b[i] = number.nextInt() b[i] b i number.nextInt() number.nextInt number if(i == 1 || max < b[i] - min) max = b[i] - min; i == 1 || max < b[i] - min i == 1 i 1 max < b[i] - min max b[i] - min b[i] b i min max = b[i] - min max b[i] - min b[i] b i min if(i == 0 || b[i] < min) min = b[i]; i == 0 || b[i] < min i == 0 i 0 b[i] < min b[i] b i min min = b[i] min b[i] b i System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main {
	public static void main(String[] args) {
		Scanner number = new Scanner(System.in);
		int a  = number.nextInt();
		int[] b = new int[a];
		int c = 0,max = 0,min = 0;
		double d;

		for(int i = 0;i < a;i++) {
			b[i] = number.nextInt();
			
				
				
			if(i == 1 || max < b[i] - min) max = b[i] - min;
			if(i == 0 || b[i] < min) min = b[i];
			
			
		}
		System.out.println(max);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner number = new Scanner(System.in);
		int a  = number.nextInt();
		int[] b = new int[a];
		int c = 0,max = 0,min = 0;
		double d;

		for(int i = 0;i < a;i++) {
			b[i] = number.nextInt();
			
				
				
			if(i == 1 || max < b[i] - min) max = b[i] - min;
			if(i == 0 || b[i] < min) min = b[i];
			
			
		}
		System.out.println(max);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner number = new Scanner(System.in);
		int a  = number.nextInt();
		int[] b = new int[a];
		int c = 0,max = 0,min = 0;
		double d;

		for(int i = 0;i < a;i++) {
			b[i] = number.nextInt();
			
				
				
			if(i == 1 || max < b[i] - min) max = b[i] - min;
			if(i == 0 || b[i] < min) min = b[i];
			
			
		}
		System.out.println(max);
	}
}

