import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner s = new Scanner(System.in);

		int n = s.nextInt();
		
		int max = -2000000000;
		int min = s.nextInt();
		
		for (int i = 1; i < n; i++) {
			int r = s.nextInt();
			max = Math.max(max, r-min);
			min = Math.min(min, r);
		}
		
		System.out.println(max);
	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws IOException {
		Scanner s = new Scanner(System.in);

		int n = s.nextInt();
		
		int max = -2000000000;
		int min = s.nextInt();
		
		for (int i = 1; i < n; i++) {
			int r = s.nextInt();
			max = Math.max(max, r-min);
			min = Math.min(min, r);
		}
		
		System.out.println(max);
	}
} Main public static void main(String[] args) throws IOException {
		Scanner s = new Scanner(System.in);

		int n = s.nextInt();
		
		int max = -2000000000;
		int min = s.nextInt();
		
		for (int i = 1; i < n; i++) {
			int r = s.nextInt();
			max = Math.max(max, r-min);
			min = Math.min(min, r);
		}
		
		System.out.println(max);
	} main {
		Scanner s = new Scanner(System.in);

		int n = s.nextInt();
		
		int max = -2000000000;
		int min = s.nextInt();
		
		for (int i = 1; i < n; i++) {
			int r = s.nextInt();
			max = Math.max(max, r-min);
			min = Math.min(min, r);
		}
		
		System.out.println(max);
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) int n = s.nextInt(); n s.nextInt() s.nextInt s int max = -2000000000; max -2000000000 2000000000 int min = s.nextInt(); min s.nextInt() s.nextInt s for (int i = 1; i < n; i++) {
			int r = s.nextInt();
			max = Math.max(max, r-min);
			min = Math.min(min, r);
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			int r = s.nextInt();
			max = Math.max(max, r-min);
			min = Math.min(min, r);
		} {
			int r = s.nextInt();
			max = Math.max(max, r-min);
			min = Math.min(min, r);
		} int r = s.nextInt(); r s.nextInt() s.nextInt s 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 IOException {
		Scanner s = new Scanner(System.in);

		int n = s.nextInt();
		
		int max = -2000000000;
		int min = s.nextInt();
		
		for (int i = 1; i < n; i++) {
			int r = s.nextInt();
			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 IOException {
		Scanner s = new Scanner(System.in);

		int n = s.nextInt();
		
		int max = -2000000000;
		int min = s.nextInt();
		
		for (int i = 1; i < n; i++) {
			int r = s.nextInt();
			max = Math.max(max, r-min);
			min = Math.min(min, r);
		}
		
		System.out.println(max);
	}
} Main
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner s = new Scanner(System.in);

		int n = s.nextInt();
		
		int max = -2000000000;
		int min = s.nextInt();
		
		for (int i = 1; i < n; i++) {
			int r = s.nextInt();
			max = Math.max(max, r-min);
			min = Math.min(min, r);
		}
		
		System.out.println(max);
	}
}
