import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int[] t = new int[n];

		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}

		int max = (int) Math.pow(10, 9) * -1;
		int min = t[0];

		for (int i = 1; i < n; i++) {
			if (max < t[i] - min) {
				max = t[i] - min;
			}
			min = min > t[i] ? t[i] : min;
		}
		System.out.println(max);
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int[] t = new int[n];

		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}

		int max = (int) Math.pow(10, 9) * -1;
		int min = t[0];

		for (int i = 1; i < n; i++) {
			if (max < t[i] - min) {
				max = t[i] - min;
			}
			min = min > t[i] ? t[i] : min;
		}
		System.out.println(max);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int[] t = new int[n];

		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}

		int max = (int) Math.pow(10, 9) * -1;
		int min = t[0];

		for (int i = 1; i < n; i++) {
			if (max < t[i] - min) {
				max = t[i] - min;
			}
			min = min > t[i] ? t[i] : min;
		}
		System.out.println(max);
	} main {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int[] t = new int[n];

		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}

		int max = (int) Math.pow(10, 9) * -1;
		int min = t[0];

		for (int i = 1; i < n; i++) {
			if (max < t[i] - min) {
				max = t[i] - min;
			}
			min = min > t[i] ? t[i] : min;
		}
		System.out.println(max);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] t = new int[n]; t new int[n] n for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			t[i] = sc.nextInt();
		} {
			t[i] = sc.nextInt();
		} t[i] = sc.nextInt() t[i] t i sc.nextInt() sc.nextInt sc int max = (int) Math.pow(10, 9) * -1; max (int) Math.pow(10, 9) * -1 (int) Math.pow(10, 9) Math.pow Math 10 9 -1 1 int min = t[0]; min t[0] t 0 for (int i = 1; i < n; i++) {
			if (max < t[i] - min) {
				max = t[i] - min;
			}
			min = min > t[i] ? t[i] : min;
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			if (max < t[i] - min) {
				max = t[i] - min;
			}
			min = min > t[i] ? t[i] : min;
		} {
			if (max < t[i] - min) {
				max = t[i] - min;
			}
			min = min > t[i] ? t[i] : min;
		} if (max < t[i] - min) {
				max = t[i] - min;
			} max < t[i] - min max t[i] - min t[i] t i min {
				max = t[i] - min;
			} max = t[i] - min max t[i] - min t[i] t i min min = min > t[i] ? t[i] : min min min > t[i] ? t[i] : min min > t[i] min t[i] t i t[i] t i min 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 sc = new Scanner(System.in);

		int n = sc.nextInt();

		int[] t = new int[n];

		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}

		int max = (int) Math.pow(10, 9) * -1;
		int min = t[0];

		for (int i = 1; i < n; i++) {
			if (max < t[i] - min) {
				max = t[i] - min;
			}
			min = min > t[i] ? t[i] : min;
		}
		System.out.println(max);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int[] t = new int[n];

		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}

		int max = (int) Math.pow(10, 9) * -1;
		int min = t[0];

		for (int i = 1; i < n; i++) {
			if (max < t[i] - min) {
				max = t[i] - min;
			}
			min = min > t[i] ? t[i] : min;
		}
		System.out.println(max);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int[] t = new int[n];

		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}

		int max = (int) Math.pow(10, 9) * -1;
		int min = t[0];

		for (int i = 1; i < n; i++) {
			if (max < t[i] - min) {
				max = t[i] - min;
			}
			min = min > t[i] ? t[i] : min;
		}
		System.out.println(max);
	}

}