import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		int maxv = Integer.MIN_VALUE;
		int minv = Integer.MAX_VALUE;
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		int input;

		for (int j = 0; j < n; j++) {
			input = scanner.nextInt();
			if (j == 0) {
				minv = input;
			} else {
				maxv = Math.max(maxv, input - minv);
				minv = Math.min(minv, input);
			}
		}

		System.out.println(maxv);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {

		int maxv = Integer.MIN_VALUE;
		int minv = Integer.MAX_VALUE;
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		int input;

		for (int j = 0; j < n; j++) {
			input = scanner.nextInt();
			if (j == 0) {
				minv = input;
			} else {
				maxv = Math.max(maxv, input - minv);
				minv = Math.min(minv, input);
			}
		}

		System.out.println(maxv);
	}
} Main public static void main(String[] args) {

		int maxv = Integer.MIN_VALUE;
		int minv = Integer.MAX_VALUE;
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		int input;

		for (int j = 0; j < n; j++) {
			input = scanner.nextInt();
			if (j == 0) {
				minv = input;
			} else {
				maxv = Math.max(maxv, input - minv);
				minv = Math.min(minv, input);
			}
		}

		System.out.println(maxv);
	} main {

		int maxv = Integer.MIN_VALUE;
		int minv = Integer.MAX_VALUE;
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		int input;

		for (int j = 0; j < n; j++) {
			input = scanner.nextInt();
			if (j == 0) {
				minv = input;
			} else {
				maxv = Math.max(maxv, input - minv);
				minv = Math.min(minv, input);
			}
		}

		System.out.println(maxv);
	} int maxv = Integer.MIN_VALUE; maxv Integer.MIN_VALUE Integer Integer.MIN_VALUE int minv = Integer.MAX_VALUE; minv Integer.MAX_VALUE Integer Integer.MAX_VALUE Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int input; input for (int j = 0; j < n; j++) {
			input = scanner.nextInt();
			if (j == 0) {
				minv = input;
			} else {
				maxv = Math.max(maxv, input - minv);
				minv = Math.min(minv, input);
			}
		} int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
			input = scanner.nextInt();
			if (j == 0) {
				minv = input;
			} else {
				maxv = Math.max(maxv, input - minv);
				minv = Math.min(minv, input);
			}
		} {
			input = scanner.nextInt();
			if (j == 0) {
				minv = input;
			} else {
				maxv = Math.max(maxv, input - minv);
				minv = Math.min(minv, input);
			}
		} input = scanner.nextInt() input scanner.nextInt() scanner.nextInt scanner if (j == 0) {
				minv = input;
			} else {
				maxv = Math.max(maxv, input - minv);
				minv = Math.min(minv, input);
			} j == 0 j 0 {
				minv = input;
			} minv = input minv input {
				maxv = Math.max(maxv, input - minv);
				minv = Math.min(minv, input);
			} maxv = Math.max(maxv, input - minv) maxv Math.max(maxv, input - minv) Math.max Math maxv input - minv input minv minv = Math.min(minv, input) minv Math.min(minv, input) Math.min Math minv input System.out.println(maxv) System.out.println System.out System System.out maxv String[] args args public class Main {
	public static void main(String[] args) {

		int maxv = Integer.MIN_VALUE;
		int minv = Integer.MAX_VALUE;
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		int input;

		for (int j = 0; j < n; j++) {
			input = scanner.nextInt();
			if (j == 0) {
				minv = input;
			} else {
				maxv = Math.max(maxv, input - minv);
				minv = Math.min(minv, input);
			}
		}

		System.out.println(maxv);
	}
} public class Main {
	public static void main(String[] args) {

		int maxv = Integer.MIN_VALUE;
		int minv = Integer.MAX_VALUE;
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		int input;

		for (int j = 0; j < n; j++) {
			input = scanner.nextInt();
			if (j == 0) {
				minv = input;
			} else {
				maxv = Math.max(maxv, input - minv);
				minv = Math.min(minv, input);
			}
		}

		System.out.println(maxv);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		int maxv = Integer.MIN_VALUE;
		int minv = Integer.MAX_VALUE;
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		int input;

		for (int j = 0; j < n; j++) {
			input = scanner.nextInt();
			if (j == 0) {
				minv = input;
			} else {
				maxv = Math.max(maxv, input - minv);
				minv = Math.min(minv, input);
			}
		}

		System.out.println(maxv);
	}
}