import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = 1000000000;
		int max = -1000000000;

		for(int i = 0; i < n; i++) {

			int r = sc.nextInt();

			if(i == 0) {

				min = r;

			} else {

				max = Math.max(max, r - min);
				min = Math.min(min, r);

			}
		}

		System.out.println(max);

	}

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

	public static void main(String[] args) throws Exception {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = 1000000000;
		int max = -1000000000;

		for(int i = 0; i < n; i++) {

			int r = sc.nextInt();

			if(i == 0) {

				min = r;

			} else {

				max = Math.max(max, r - min);
				min = Math.min(min, r);

			}
		}

		System.out.println(max);

	}

} Main public static void main(String[] args) throws Exception {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = 1000000000;
		int max = -1000000000;

		for(int i = 0; i < n; i++) {

			int r = sc.nextInt();

			if(i == 0) {

				min = r;

			} else {

				max = Math.max(max, r - min);
				min = Math.min(min, r);

			}
		}

		System.out.println(max);

	} main {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = 1000000000;
		int max = -1000000000;

		for(int i = 0; i < n; i++) {

			int r = sc.nextInt();

			if(i == 0) {

				min = r;

			} else {

				max = Math.max(max, r - min);
				min = Math.min(min, r);

			}
		}

		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 min = 1000000000; min 1000000000 int max = -1000000000; max -1000000000 1000000000 for(int i = 0; i < n; i++) {

			int r = sc.nextInt();

			if(i == 0) {

				min = r;

			} else {

				max = Math.max(max, r - min);
				min = Math.min(min, r);

			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {

			int r = sc.nextInt();

			if(i == 0) {

				min = r;

			} else {

				max = Math.max(max, r - min);
				min = Math.min(min, r);

			}
		} {

			int r = sc.nextInt();

			if(i == 0) {

				min = r;

			} else {

				max = Math.max(max, r - min);
				min = Math.min(min, r);

			}
		} int r = sc.nextInt(); r sc.nextInt() sc.nextInt sc if(i == 0) {

				min = r;

			} else {

				max = Math.max(max, r - min);
				min = Math.min(min, r);

			} i == 0 i 0 {

				min = r;

			} min = r min r {

				max = Math.max(max, r - min);
				min = Math.min(min, r);

			} max = Math.max(max, r - min) max Math.max(max, r - min) Math.max Math max r - min r min min = Math.min(min, r) min Math.min(min, r) Math.min Math min r 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) throws Exception {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = 1000000000;
		int max = -1000000000;

		for(int i = 0; i < n; i++) {

			int r = sc.nextInt();

			if(i == 0) {

				min = r;

			} else {

				max = Math.max(max, r - min);
				min = Math.min(min, r);

			}
		}

		System.out.println(max);

	}

} public class Main {

	public static void main(String[] args) throws Exception {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = 1000000000;
		int max = -1000000000;

		for(int i = 0; i < n; i++) {

			int r = sc.nextInt();

			if(i == 0) {

				min = r;

			} else {

				max = Math.max(max, r - min);
				min = Math.min(min, r);

			}
		}

		System.out.println(max);

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = 1000000000;
		int max = -1000000000;

		for(int i = 0; i < n; i++) {

			int r = sc.nextInt();

			if(i == 0) {

				min = r;

			} else {

				max = Math.max(max, r - min);
				min = Math.min(min, r);

			}
		}

		System.out.println(max);

	}

}
