import java.util.Scanner;

public class Main {
	
	//?????????????????????????????????????????????????????§?????¢???????????????
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int smallerNum = sc.nextInt();
		int maxDef = Integer.MIN_VALUE;
		
		for (int i = 0; i < num - 1; i++) {
			int j = sc.nextInt();
			maxDef = Math.max(maxDef, j - smallerNum);
			smallerNum = Math.min(smallerNum, j);
		}
		System.out.println(maxDef);
	}	
} import java.util.Scanner; Scanner java.util public class Main {
	
	//?????????????????????????????????????????????????????§?????¢???????????????
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int smallerNum = sc.nextInt();
		int maxDef = Integer.MIN_VALUE;
		
		for (int i = 0; i < num - 1; i++) {
			int j = sc.nextInt();
			maxDef = Math.max(maxDef, j - smallerNum);
			smallerNum = Math.min(smallerNum, j);
		}
		System.out.println(maxDef);
	}	
} Main //?????????????????????????????????????????????????????§?????¢???????????????
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int smallerNum = sc.nextInt();
		int maxDef = Integer.MIN_VALUE;
		
		for (int i = 0; i < num - 1; i++) {
			int j = sc.nextInt();
			maxDef = Math.max(maxDef, j - smallerNum);
			smallerNum = Math.min(smallerNum, j);
		}
		System.out.println(maxDef);
	} main {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int smallerNum = sc.nextInt();
		int maxDef = Integer.MIN_VALUE;
		
		for (int i = 0; i < num - 1; i++) {
			int j = sc.nextInt();
			maxDef = Math.max(maxDef, j - smallerNum);
			smallerNum = Math.min(smallerNum, j);
		}
		System.out.println(maxDef);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc int smallerNum = sc.nextInt(); smallerNum sc.nextInt() sc.nextInt sc int maxDef = Integer.MIN_VALUE; maxDef Integer.MIN_VALUE Integer Integer.MIN_VALUE for (int i = 0; i < num - 1; i++) {
			int j = sc.nextInt();
			maxDef = Math.max(maxDef, j - smallerNum);
			smallerNum = Math.min(smallerNum, j);
		} int i = 0; int i = 0; i 0 i < num - 1 i num - 1 num 1 i++ i++ i {
			int j = sc.nextInt();
			maxDef = Math.max(maxDef, j - smallerNum);
			smallerNum = Math.min(smallerNum, j);
		} {
			int j = sc.nextInt();
			maxDef = Math.max(maxDef, j - smallerNum);
			smallerNum = Math.min(smallerNum, j);
		} int j = sc.nextInt(); j sc.nextInt() sc.nextInt sc maxDef = Math.max(maxDef, j - smallerNum) maxDef Math.max(maxDef, j - smallerNum) Math.max Math maxDef j - smallerNum j smallerNum smallerNum = Math.min(smallerNum, j) smallerNum Math.min(smallerNum, j) Math.min Math smallerNum j System.out.println(maxDef) System.out.println System.out System System.out maxDef String[] args args public class Main {
	
	//?????????????????????????????????????????????????????§?????¢???????????????
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int smallerNum = sc.nextInt();
		int maxDef = Integer.MIN_VALUE;
		
		for (int i = 0; i < num - 1; i++) {
			int j = sc.nextInt();
			maxDef = Math.max(maxDef, j - smallerNum);
			smallerNum = Math.min(smallerNum, j);
		}
		System.out.println(maxDef);
	}	
} public class Main {
	
	//?????????????????????????????????????????????????????§?????¢???????????????
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int smallerNum = sc.nextInt();
		int maxDef = Integer.MIN_VALUE;
		
		for (int i = 0; i < num - 1; i++) {
			int j = sc.nextInt();
			maxDef = Math.max(maxDef, j - smallerNum);
			smallerNum = Math.min(smallerNum, j);
		}
		System.out.println(maxDef);
	}	
} Main
import java.util.Scanner;

public class Main {
	
	//?????????????????????????????????????????????????????§?????¢???????????????
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int smallerNum = sc.nextInt();
		int maxDef = Integer.MIN_VALUE;
		
		for (int i = 0; i < num - 1; i++) {
			int j = sc.nextInt();
			maxDef = Math.max(maxDef, j - smallerNum);
			smallerNum = Math.min(smallerNum, j);
		}
		System.out.println(maxDef);
	}	
}