import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int min = scan.nextInt();
		int r = scan.nextInt();
		int maxLong = r - min;
		if (min > r){
			min = r;
		}
		for (int i = 0; i < N - 2; i++) {
			r = scan.nextInt();
			if (maxLong < r - min) {
				maxLong = r - min;
			}
			if (r < min) {
				min = r;
			}
		}
		System.out.println(maxLong);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int min = scan.nextInt();
		int r = scan.nextInt();
		int maxLong = r - min;
		if (min > r){
			min = r;
		}
		for (int i = 0; i < N - 2; i++) {
			r = scan.nextInt();
			if (maxLong < r - min) {
				maxLong = r - min;
			}
			if (r < min) {
				min = r;
			}
		}
		System.out.println(maxLong);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int min = scan.nextInt();
		int r = scan.nextInt();
		int maxLong = r - min;
		if (min > r){
			min = r;
		}
		for (int i = 0; i < N - 2; i++) {
			r = scan.nextInt();
			if (maxLong < r - min) {
				maxLong = r - min;
			}
			if (r < min) {
				min = r;
			}
		}
		System.out.println(maxLong);
	} main {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int min = scan.nextInt();
		int r = scan.nextInt();
		int maxLong = r - min;
		if (min > r){
			min = r;
		}
		for (int i = 0; i < N - 2; i++) {
			r = scan.nextInt();
			if (maxLong < r - min) {
				maxLong = r - min;
			}
			if (r < min) {
				min = r;
			}
		}
		System.out.println(maxLong);
	} 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 r = scan.nextInt(); r scan.nextInt() scan.nextInt scan int maxLong = r - min; maxLong r - min r min if (min > r){
			min = r;
		} min > r min r {
			min = r;
		} min = r min r for (int i = 0; i < N - 2; i++) {
			r = scan.nextInt();
			if (maxLong < r - min) {
				maxLong = r - min;
			}
			if (r < min) {
				min = r;
			}
		} int i = 0; int i = 0; i 0 i < N - 2 i N - 2 N 2 i++ i++ i {
			r = scan.nextInt();
			if (maxLong < r - min) {
				maxLong = r - min;
			}
			if (r < min) {
				min = r;
			}
		} {
			r = scan.nextInt();
			if (maxLong < r - min) {
				maxLong = r - min;
			}
			if (r < min) {
				min = r;
			}
		} r = scan.nextInt() r scan.nextInt() scan.nextInt scan if (maxLong < r - min) {
				maxLong = r - min;
			} maxLong < r - min maxLong r - min r min {
				maxLong = r - min;
			} maxLong = r - min maxLong r - min r min if (r < min) {
				min = r;
			} r < min r min {
				min = r;
			} min = r min r System.out.println(maxLong) System.out.println System.out System System.out maxLong String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int min = scan.nextInt();
		int r = scan.nextInt();
		int maxLong = r - min;
		if (min > r){
			min = r;
		}
		for (int i = 0; i < N - 2; i++) {
			r = scan.nextInt();
			if (maxLong < r - min) {
				maxLong = r - min;
			}
			if (r < min) {
				min = r;
			}
		}
		System.out.println(maxLong);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int min = scan.nextInt();
		int r = scan.nextInt();
		int maxLong = r - min;
		if (min > r){
			min = r;
		}
		for (int i = 0; i < N - 2; i++) {
			r = scan.nextInt();
			if (maxLong < r - min) {
				maxLong = r - min;
			}
			if (r < min) {
				min = r;
			}
		}
		System.out.println(maxLong);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int min = scan.nextInt();
		int r = scan.nextInt();
		int maxLong = r - min;
		if (min > r){
			min = r;
		}
		for (int i = 0; i < N - 2; i++) {
			r = scan.nextInt();
			if (maxLong < r - min) {
				maxLong = r - min;
			}
			if (r < min) {
				min = r;
			}
		}
		System.out.println(maxLong);
	}
}