import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int min = scan.nextInt();
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < n - 1; i++) {
			int r = scan.nextInt();
			ans = Math.max(ans, r - min);
			min = Math.min(min, r);
		}
		System.out.println(ans);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int min = scan.nextInt();
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < n - 1; i++) {
			int r = scan.nextInt();
			ans = Math.max(ans, r - min);
			min = Math.min(min, r);
		}
		System.out.println(ans);
	}
	public static void main(String[] args) {
		new Main().run();
	}
} Main void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int min = scan.nextInt();
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < n - 1; i++) {
			int r = scan.nextInt();
			ans = Math.max(ans, r - min);
			min = Math.min(min, r);
		}
		System.out.println(ans);
	} run {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int min = scan.nextInt();
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < n - 1; i++) {
			int r = scan.nextInt();
			ans = Math.max(ans, r - min);
			min = Math.min(min, r);
		}
		System.out.println(ans);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int min = scan.nextInt(); min scan.nextInt() scan.nextInt scan int ans = Integer.MIN_VALUE; ans Integer.MIN_VALUE Integer Integer.MIN_VALUE for (int i = 0; i < n - 1; i++) {
			int r = scan.nextInt();
			ans = Math.max(ans, r - min);
			min = Math.min(min, r);
		} int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
			int r = scan.nextInt();
			ans = Math.max(ans, r - min);
			min = Math.min(min, r);
		} {
			int r = scan.nextInt();
			ans = Math.max(ans, r - min);
			min = Math.min(min, r);
		} int r = scan.nextInt(); r scan.nextInt() scan.nextInt scan ans = Math.max(ans, r - min) ans Math.max(ans, r - min) Math.max Math ans r - min r min min = Math.min(min, r) min Math.min(min, r) Math.min Math min r System.out.println(ans) System.out.println System.out System System.out ans public static void main(String[] args) {
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int min = scan.nextInt();
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < n - 1; i++) {
			int r = scan.nextInt();
			ans = Math.max(ans, r - min);
			min = Math.min(min, r);
		}
		System.out.println(ans);
	}
	public static void main(String[] args) {
		new Main().run();
	}
} public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int min = scan.nextInt();
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < n - 1; i++) {
			int r = scan.nextInt();
			ans = Math.max(ans, r - min);
			min = Math.min(min, r);
		}
		System.out.println(ans);
	}
	public static void main(String[] args) {
		new Main().run();
	}
} Main
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int min = scan.nextInt();
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < n - 1; i++) {
			int r = scan.nextInt();
			ans = Math.max(ans, r - min);
			min = Math.min(min, r);
		}
		System.out.println(ans);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

