import java.util.Scanner;

// ALDS1_1_D
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r, p = 0, max = 1 - 1000000000;
		for (int i = 0; i < n; i++) {
			r = sc.nextInt();
			if (i == 0) {
				p = r;
			} else {
				if (max < r - p) max = r - p;
				if (r < p) p = r;
			}
		}
		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 r, p = 0, max = 1 - 1000000000;
		for (int i = 0; i < n; i++) {
			r = sc.nextInt();
			if (i == 0) {
				p = r;
			} else {
				if (max < r - p) max = r - p;
				if (r < p) p = r;
			}
		}
		System.out.println(max);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r, p = 0, max = 1 - 1000000000;
		for (int i = 0; i < n; i++) {
			r = sc.nextInt();
			if (i == 0) {
				p = r;
			} else {
				if (max < r - p) max = r - p;
				if (r < p) p = r;
			}
		}
		System.out.println(max);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r, p = 0, max = 1 - 1000000000;
		for (int i = 0; i < n; i++) {
			r = sc.nextInt();
			if (i == 0) {
				p = r;
			} else {
				if (max < r - p) max = r - p;
				if (r < p) p = 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 r r p = 0 p 0 max = 1 - 1000000000; max 1 - 1000000000 1 1000000000 for (int i = 0; i < n; i++) {
			r = sc.nextInt();
			if (i == 0) {
				p = r;
			} else {
				if (max < r - p) max = r - p;
				if (r < p) p = r;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			r = sc.nextInt();
			if (i == 0) {
				p = r;
			} else {
				if (max < r - p) max = r - p;
				if (r < p) p = r;
			}
		} {
			r = sc.nextInt();
			if (i == 0) {
				p = r;
			} else {
				if (max < r - p) max = r - p;
				if (r < p) p = r;
			}
		} r = sc.nextInt() r sc.nextInt() sc.nextInt sc if (i == 0) {
				p = r;
			} else {
				if (max < r - p) max = r - p;
				if (r < p) p = r;
			} i == 0 i 0 {
				p = r;
			} p = r p r {
				if (max < r - p) max = r - p;
				if (r < p) p = r;
			} if (max < r - p) max = r - p; max < r - p max r - p r p max = r - p max r - p r p if (r < p) p = r; r < p r p p = r p 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) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r, p = 0, max = 1 - 1000000000;
		for (int i = 0; i < n; i++) {
			r = sc.nextInt();
			if (i == 0) {
				p = r;
			} else {
				if (max < r - p) max = r - p;
				if (r < p) p = r;
			}
		}
		System.out.println(max);
	}
} public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r, p = 0, max = 1 - 1000000000;
		for (int i = 0; i < n; i++) {
			r = sc.nextInt();
			if (i == 0) {
				p = r;
			} else {
				if (max < r - p) max = r - p;
				if (r < p) p = r;
			}
		}
		System.out.println(max);
	}
} Main
import java.util.Scanner;

// ALDS1_1_D
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r, p = 0, max = 1 - 1000000000;
		for (int i = 0; i < n; i++) {
			r = sc.nextInt();
			if (i == 0) {
				p = r;
			} else {
				if (max < r - p) max = r - p;
				if (r < p) p = r;
			}
		}
		System.out.println(max);
	}
}

