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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] price = new int[n];

		for (int i = 0; i < n; i++) {
			price[i] = Integer.parseInt(br.readLine());
		}

		int max = - Integer.MIN_VALUE;
		int minPrice = price[0];
		for (int i = 1; i < n; i++) {
			if (max < price[i] - minPrice) {
				max = price[i] - minPrice;
			}
			if (minPrice > price[i]) {
				minPrice = price[i];
			}
		}
		System.out.println(max);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] price = new int[n];

		for (int i = 0; i < n; i++) {
			price[i] = Integer.parseInt(br.readLine());
		}

		int max = - Integer.MIN_VALUE;
		int minPrice = price[0];
		for (int i = 1; i < n; i++) {
			if (max < price[i] - minPrice) {
				max = price[i] - minPrice;
			}
			if (minPrice > price[i]) {
				minPrice = price[i];
			}
		}
		System.out.println(max);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] price = new int[n];

		for (int i = 0; i < n; i++) {
			price[i] = Integer.parseInt(br.readLine());
		}

		int max = - Integer.MIN_VALUE;
		int minPrice = price[0];
		for (int i = 1; i < n; i++) {
			if (max < price[i] - minPrice) {
				max = price[i] - minPrice;
			}
			if (minPrice > price[i]) {
				minPrice = price[i];
			}
		}
		System.out.println(max);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] price = new int[n];

		for (int i = 0; i < n; i++) {
			price[i] = Integer.parseInt(br.readLine());
		}

		int max = - Integer.MIN_VALUE;
		int minPrice = price[0];
		for (int i = 1; i < n; i++) {
			if (max < price[i] - minPrice) {
				max = price[i] - minPrice;
			}
			if (minPrice > price[i]) {
				minPrice = price[i];
			}
		}
		System.out.println(max);
	} 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[] price = new int[n]; price new int[n] n for (int i = 0; i < n; i++) {
			price[i] = Integer.parseInt(br.readLine());
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			price[i] = Integer.parseInt(br.readLine());
		} {
			price[i] = Integer.parseInt(br.readLine());
		} price[i] = Integer.parseInt(br.readLine()) price[i] price i Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int max = - Integer.MIN_VALUE; max - Integer.MIN_VALUE Integer.MIN_VALUE Integer Integer.MIN_VALUE int minPrice = price[0]; minPrice price[0] price 0 for (int i = 1; i < n; i++) {
			if (max < price[i] - minPrice) {
				max = price[i] - minPrice;
			}
			if (minPrice > price[i]) {
				minPrice = price[i];
			}
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			if (max < price[i] - minPrice) {
				max = price[i] - minPrice;
			}
			if (minPrice > price[i]) {
				minPrice = price[i];
			}
		} {
			if (max < price[i] - minPrice) {
				max = price[i] - minPrice;
			}
			if (minPrice > price[i]) {
				minPrice = price[i];
			}
		} if (max < price[i] - minPrice) {
				max = price[i] - minPrice;
			} max < price[i] - minPrice max price[i] - minPrice price[i] price i minPrice {
				max = price[i] - minPrice;
			} max = price[i] - minPrice max price[i] - minPrice price[i] price i minPrice if (minPrice > price[i]) {
				minPrice = price[i];
			} minPrice > price[i] minPrice price[i] price i {
				minPrice = price[i];
			} minPrice = price[i] minPrice price[i] price i 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));
		int n = Integer.parseInt(br.readLine());
		int[] price = new int[n];

		for (int i = 0; i < n; i++) {
			price[i] = Integer.parseInt(br.readLine());
		}

		int max = - Integer.MIN_VALUE;
		int minPrice = price[0];
		for (int i = 1; i < n; i++) {
			if (max < price[i] - minPrice) {
				max = price[i] - minPrice;
			}
			if (minPrice > price[i]) {
				minPrice = price[i];
			}
		}
		System.out.println(max);
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] price = new int[n];

		for (int i = 0; i < n; i++) {
			price[i] = Integer.parseInt(br.readLine());
		}

		int max = - Integer.MIN_VALUE;
		int minPrice = price[0];
		for (int i = 1; i < n; i++) {
			if (max < price[i] - minPrice) {
				max = price[i] - minPrice;
			}
			if (minPrice > price[i]) {
				minPrice = price[i];
			}
		}
		System.out.println(max);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] price = new int[n];

		for (int i = 0; i < n; i++) {
			price[i] = Integer.parseInt(br.readLine());
		}

		int max = - Integer.MIN_VALUE;
		int minPrice = price[0];
		for (int i = 1; i < n; i++) {
			if (max < price[i] - minPrice) {
				max = price[i] - minPrice;
			}
			if (minPrice > price[i]) {
				minPrice = price[i];
			}
		}
		System.out.println(max);
	}
}