import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	void run() throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());

		int[] number = new int[N];
		for (int i = 0; i < N; i++) {
			number[i] = Integer.parseInt(br.readLine());
		}

		int maxv = -1000000000;
		int minv = number[0];
		for (int i = 1; i < N; i++) {
			maxv = Math.max(maxv, number[i] - minv); 
			minv = Math.min(number[i], minv);
		}
		System.out.println(maxv);
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	void run() throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());

		int[] number = new int[N];
		for (int i = 0; i < N; i++) {
			number[i] = Integer.parseInt(br.readLine());
		}

		int maxv = -1000000000;
		int minv = number[0];
		for (int i = 1; i < N; i++) {
			maxv = Math.max(maxv, number[i] - minv); 
			minv = Math.min(number[i], minv);
		}
		System.out.println(maxv);
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
} Main void run() throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());

		int[] number = new int[N];
		for (int i = 0; i < N; i++) {
			number[i] = Integer.parseInt(br.readLine());
		}

		int maxv = -1000000000;
		int minv = number[0];
		for (int i = 1; i < N; i++) {
			maxv = Math.max(maxv, number[i] - minv); 
			minv = Math.min(number[i], minv);
		}
		System.out.println(maxv);
	} run {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());

		int[] number = new int[N];
		for (int i = 0; i < N; i++) {
			number[i] = Integer.parseInt(br.readLine());
		}

		int maxv = -1000000000;
		int minv = number[0];
		for (int i = 1; i < N; i++) {
			maxv = Math.max(maxv, number[i] - minv); 
			minv = Math.min(number[i], minv);
		}
		System.out.println(maxv);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int N = Integer.parseInt(br.readLine()); N Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int[] number = new int[N]; number new int[N] N for (int i = 0; i < N; i++) {
			number[i] = Integer.parseInt(br.readLine());
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			number[i] = Integer.parseInt(br.readLine());
		} {
			number[i] = Integer.parseInt(br.readLine());
		} number[i] = Integer.parseInt(br.readLine()) number[i] number i Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int maxv = -1000000000; maxv -1000000000 1000000000 int minv = number[0]; minv number[0] number 0 for (int i = 1; i < N; i++) {
			maxv = Math.max(maxv, number[i] - minv); 
			minv = Math.min(number[i], minv);
		} int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
			maxv = Math.max(maxv, number[i] - minv); 
			minv = Math.min(number[i], minv);
		} {
			maxv = Math.max(maxv, number[i] - minv); 
			minv = Math.min(number[i], minv);
		} maxv = Math.max(maxv, number[i] - minv) maxv Math.max(maxv, number[i] - minv) Math.max Math maxv number[i] - minv number[i] number i minv minv = Math.min(number[i], minv) minv Math.min(number[i], minv) Math.min Math number[i] number i minv System.out.println(maxv) System.out.println System.out System System.out maxv public static void main(String[] args) throws IOException {
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args public class Main {

	void run() throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());

		int[] number = new int[N];
		for (int i = 0; i < N; i++) {
			number[i] = Integer.parseInt(br.readLine());
		}

		int maxv = -1000000000;
		int minv = number[0];
		for (int i = 1; i < N; i++) {
			maxv = Math.max(maxv, number[i] - minv); 
			minv = Math.min(number[i], minv);
		}
		System.out.println(maxv);
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
} public class Main {

	void run() throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());

		int[] number = new int[N];
		for (int i = 0; i < N; i++) {
			number[i] = Integer.parseInt(br.readLine());
		}

		int maxv = -1000000000;
		int minv = number[0];
		for (int i = 1; i < N; i++) {
			maxv = Math.max(maxv, number[i] - minv); 
			minv = Math.min(number[i], minv);
		}
		System.out.println(maxv);
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	void run() throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());

		int[] number = new int[N];
		for (int i = 0; i < N; i++) {
			number[i] = Integer.parseInt(br.readLine());
		}

		int maxv = -1000000000;
		int minv = number[0];
		for (int i = 1; i < N; i++) {
			maxv = Math.max(maxv, number[i] - minv); 
			minv = Math.min(number[i], minv);
		}
		System.out.println(maxv);
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
}