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

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine()), maximum = Integer.MIN_VALUE, minimum;
		int[] timeRate = new int[n];
		for (int i = 0; i < n; i++) {
			timeRate[i] = Integer.parseInt(in.readLine());
		}
		minimum = timeRate[0];
		for (int x = 1; x < n; x++) {
			if (maximum < timeRate[x] - minimum) {
				maximum = timeRate[x] - minimum;
			}
			if (minimum > timeRate[x]) {
				minimum = timeRate[x];
			}
		}
		System.out.println(maximum);
	}
} 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 NumberFormatException,
			IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine()), maximum = Integer.MIN_VALUE, minimum;
		int[] timeRate = new int[n];
		for (int i = 0; i < n; i++) {
			timeRate[i] = Integer.parseInt(in.readLine());
		}
		minimum = timeRate[0];
		for (int x = 1; x < n; x++) {
			if (maximum < timeRate[x] - minimum) {
				maximum = timeRate[x] - minimum;
			}
			if (minimum > timeRate[x]) {
				minimum = timeRate[x];
			}
		}
		System.out.println(maximum);
	}
} Main public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine()), maximum = Integer.MIN_VALUE, minimum;
		int[] timeRate = new int[n];
		for (int i = 0; i < n; i++) {
			timeRate[i] = Integer.parseInt(in.readLine());
		}
		minimum = timeRate[0];
		for (int x = 1; x < n; x++) {
			if (maximum < timeRate[x] - minimum) {
				maximum = timeRate[x] - minimum;
			}
			if (minimum > timeRate[x]) {
				minimum = timeRate[x];
			}
		}
		System.out.println(maximum);
	} main {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine()), maximum = Integer.MIN_VALUE, minimum;
		int[] timeRate = new int[n];
		for (int i = 0; i < n; i++) {
			timeRate[i] = Integer.parseInt(in.readLine());
		}
		minimum = timeRate[0];
		for (int x = 1; x < n; x++) {
			if (maximum < timeRate[x] - minimum) {
				maximum = timeRate[x] - minimum;
			}
			if (minimum > timeRate[x]) {
				minimum = timeRate[x];
			}
		}
		System.out.println(maximum);
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(in.readLine()) n Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in maximum = Integer.MIN_VALUE maximum Integer.MIN_VALUE Integer Integer.MIN_VALUE minimum; minimum int[] timeRate = new int[n]; timeRate new int[n] n for (int i = 0; i < n; i++) {
			timeRate[i] = Integer.parseInt(in.readLine());
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			timeRate[i] = Integer.parseInt(in.readLine());
		} {
			timeRate[i] = Integer.parseInt(in.readLine());
		} timeRate[i] = Integer.parseInt(in.readLine()) timeRate[i] timeRate i Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in minimum = timeRate[0] minimum timeRate[0] timeRate 0 for (int x = 1; x < n; x++) {
			if (maximum < timeRate[x] - minimum) {
				maximum = timeRate[x] - minimum;
			}
			if (minimum > timeRate[x]) {
				minimum = timeRate[x];
			}
		} int x = 1; int x = 1; x 1 x < n x n x++ x++ x {
			if (maximum < timeRate[x] - minimum) {
				maximum = timeRate[x] - minimum;
			}
			if (minimum > timeRate[x]) {
				minimum = timeRate[x];
			}
		} {
			if (maximum < timeRate[x] - minimum) {
				maximum = timeRate[x] - minimum;
			}
			if (minimum > timeRate[x]) {
				minimum = timeRate[x];
			}
		} if (maximum < timeRate[x] - minimum) {
				maximum = timeRate[x] - minimum;
			} maximum < timeRate[x] - minimum maximum timeRate[x] - minimum timeRate[x] timeRate x minimum {
				maximum = timeRate[x] - minimum;
			} maximum = timeRate[x] - minimum maximum timeRate[x] - minimum timeRate[x] timeRate x minimum if (minimum > timeRate[x]) {
				minimum = timeRate[x];
			} minimum > timeRate[x] minimum timeRate[x] timeRate x {
				minimum = timeRate[x];
			} minimum = timeRate[x] minimum timeRate[x] timeRate x System.out.println(maximum) System.out.println System.out System System.out maximum String[] args args public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine()), maximum = Integer.MIN_VALUE, minimum;
		int[] timeRate = new int[n];
		for (int i = 0; i < n; i++) {
			timeRate[i] = Integer.parseInt(in.readLine());
		}
		minimum = timeRate[0];
		for (int x = 1; x < n; x++) {
			if (maximum < timeRate[x] - minimum) {
				maximum = timeRate[x] - minimum;
			}
			if (minimum > timeRate[x]) {
				minimum = timeRate[x];
			}
		}
		System.out.println(maximum);
	}
} public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine()), maximum = Integer.MIN_VALUE, minimum;
		int[] timeRate = new int[n];
		for (int i = 0; i < n; i++) {
			timeRate[i] = Integer.parseInt(in.readLine());
		}
		minimum = timeRate[0];
		for (int x = 1; x < n; x++) {
			if (maximum < timeRate[x] - minimum) {
				maximum = timeRate[x] - minimum;
			}
			if (minimum > timeRate[x]) {
				minimum = timeRate[x];
			}
		}
		System.out.println(maximum);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine()), maximum = Integer.MIN_VALUE, minimum;
		int[] timeRate = new int[n];
		for (int i = 0; i < n; i++) {
			timeRate[i] = Integer.parseInt(in.readLine());
		}
		minimum = timeRate[0];
		for (int x = 1; x < n; x++) {
			if (maximum < timeRate[x] - minimum) {
				maximum = timeRate[x] - minimum;
			}
			if (minimum > timeRate[x]) {
				minimum = timeRate[x];
			}
		}
		System.out.println(maximum);
	}
}