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

import static java.lang.Integer.parseInt;

/**
 * Getting Started - Maximum Profit
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int n = parseInt(br.readLine());

		int max = (int) -Math.pow(10, 9);
		int min = parseInt(br.readLine());

		for (int i = 0; i < n - 1; i++) {
			int r = parseInt(br.readLine());
			max = Math.max(max, r - min);
			min = Math.min(min, r);
		}
		System.out.println(max);
		
	} //end main
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import static java.lang.Integer.parseInt; import static java.lang.Integer.parseInt; import static java.lang.Integer.parseInt; public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int n = parseInt(br.readLine());

		int max = (int) -Math.pow(10, 9);
		int min = parseInt(br.readLine());

		for (int i = 0; i < n - 1; i++) {
			int r = parseInt(br.readLine());
			max = Math.max(max, r - min);
			min = Math.min(min, r);
		}
		System.out.println(max);
		
	} //end main
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int n = parseInt(br.readLine());

		int max = (int) -Math.pow(10, 9);
		int min = parseInt(br.readLine());

		for (int i = 0; i < n - 1; i++) {
			int r = parseInt(br.readLine());
			max = Math.max(max, r - min);
			min = Math.min(min, r);
		}
		System.out.println(max);
		
	} //end main main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int n = parseInt(br.readLine());

		int max = (int) -Math.pow(10, 9);
		int min = parseInt(br.readLine());

		for (int i = 0; i < n - 1; i++) {
			int r = parseInt(br.readLine());
			max = Math.max(max, r - min);
			min = Math.min(min, r);
		}
		System.out.println(max);
		
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line; line int n = parseInt(br.readLine()); n parseInt(br.readLine()) parseInt br.readLine() br.readLine br int max = (int) -Math.pow(10, 9); max (int) -Math.pow(10, 9) Math.pow(10, 9) Math.pow Math 10 9 int min = parseInt(br.readLine()); min parseInt(br.readLine()) parseInt br.readLine() br.readLine br for (int i = 0; i < n - 1; i++) {
			int r = parseInt(br.readLine());
			max = Math.max(max, r - min);
			min = Math.min(min, r);
		} int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
			int r = parseInt(br.readLine());
			max = Math.max(max, r - min);
			min = Math.min(min, r);
		} {
			int r = parseInt(br.readLine());
			max = Math.max(max, r - min);
			min = Math.min(min, r);
		} int r = parseInt(br.readLine()); r parseInt(br.readLine()) parseInt br.readLine() br.readLine br 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 {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int n = parseInt(br.readLine());

		int max = (int) -Math.pow(10, 9);
		int min = parseInt(br.readLine());

		for (int i = 0; i < n - 1; i++) {
			int r = parseInt(br.readLine());
			max = Math.max(max, r - min);
			min = Math.min(min, r);
		}
		System.out.println(max);
		
	} //end main
} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int n = parseInt(br.readLine());

		int max = (int) -Math.pow(10, 9);
		int min = parseInt(br.readLine());

		for (int i = 0; i < n - 1; i++) {
			int r = parseInt(br.readLine());
			max = Math.max(max, r - min);
			min = Math.min(min, r);
		}
		System.out.println(max);
		
	} //end main
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Getting Started - Maximum Profit
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int n = parseInt(br.readLine());

		int max = (int) -Math.pow(10, 9);
		int min = parseInt(br.readLine());

		for (int i = 0; i < n - 1; i++) {
			int r = parseInt(br.readLine());
			max = Math.max(max, r - min);
			min = Math.min(min, r);
		}
		System.out.println(max);
		
	} //end main
}