
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int minv = Integer.MAX_VALUE;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int j = scanner.nextInt();
			if (i > 0)
				maxv = Math.max(maxv, j - minv);
			minv = Math.min(minv, j);
		}
		System.out.println(maxv);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int minv = Integer.MAX_VALUE;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int j = scanner.nextInt();
			if (i > 0)
				maxv = Math.max(maxv, j - minv);
			minv = Math.min(minv, j);
		}
		System.out.println(maxv);
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int minv = Integer.MAX_VALUE;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int j = scanner.nextInt();
			if (i > 0)
				maxv = Math.max(maxv, j - minv);
			minv = Math.min(minv, j);
		}
		System.out.println(maxv);
	} main {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int minv = Integer.MAX_VALUE;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int j = scanner.nextInt();
			if (i > 0)
				maxv = Math.max(maxv, j - minv);
			minv = Math.min(minv, j);
		}
		System.out.println(maxv);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int minv = Integer.MAX_VALUE; minv Integer.MAX_VALUE Integer Integer.MAX_VALUE int maxv = Integer.MIN_VALUE; maxv Integer.MIN_VALUE Integer Integer.MIN_VALUE for (int i = 0; i < n; i++) {
			int j = scanner.nextInt();
			if (i > 0)
				maxv = Math.max(maxv, j - minv);
			minv = Math.min(minv, j);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int j = scanner.nextInt();
			if (i > 0)
				maxv = Math.max(maxv, j - minv);
			minv = Math.min(minv, j);
		} {
			int j = scanner.nextInt();
			if (i > 0)
				maxv = Math.max(maxv, j - minv);
			minv = Math.min(minv, j);
		} int j = scanner.nextInt(); j scanner.nextInt() scanner.nextInt scanner if (i > 0)
				maxv = Math.max(maxv, j - minv); i > 0 i 0 maxv = Math.max(maxv, j - minv) maxv Math.max(maxv, j - minv) Math.max Math maxv j - minv j minv minv = Math.min(minv, j) minv Math.min(minv, j) Math.min Math minv j 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) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int minv = Integer.MAX_VALUE;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int j = scanner.nextInt();
			if (i > 0)
				maxv = Math.max(maxv, j - minv);
			minv = Math.min(minv, j);
		}
		System.out.println(maxv);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int minv = Integer.MAX_VALUE;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int j = scanner.nextInt();
			if (i > 0)
				maxv = Math.max(maxv, j - minv);
			minv = Math.min(minv, j);
		}
		System.out.println(maxv);
	}
} Main

import java.util.Scanner;

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