
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 reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int minv = Integer.MAX_VALUE;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int j = Integer.parseInt(reader.readLine());
			if (maxv < j - minv)
				maxv = j - minv;
			if (j < minv)
				minv = j;
		}
		System.out.println(maxv);
	}
} 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 reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int minv = Integer.MAX_VALUE;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int j = Integer.parseInt(reader.readLine());
			if (maxv < j - minv)
				maxv = j - minv;
			if (j < minv)
				minv = j;
		}
		System.out.println(maxv);
	}
} Main public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int minv = Integer.MAX_VALUE;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int j = Integer.parseInt(reader.readLine());
			if (maxv < j - minv)
				maxv = j - minv;
			if (j < minv)
				minv = j;
		}
		System.out.println(maxv);
	} main {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int minv = Integer.MAX_VALUE;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int j = Integer.parseInt(reader.readLine());
			if (maxv < j - minv)
				maxv = j - minv;
			if (j < minv)
				minv = j;
		}
		System.out.println(maxv);
	} BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(reader.readLine()); n Integer.parseInt(reader.readLine()) Integer.parseInt Integer reader.readLine() reader.readLine reader int minv = Integer.MAX_VALUE; minv Integer.MAX_VALUE Integer Integer.MAX_VALUE int maxv = Integer.MIN_VALUE; maxv Integer.MIN_VALUE Integer Integer.MIN_VALUE for (int i = 0; i < n; i++) {
			int j = Integer.parseInt(reader.readLine());
			if (maxv < j - minv)
				maxv = j - minv;
			if (j < minv)
				minv = j;
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int j = Integer.parseInt(reader.readLine());
			if (maxv < j - minv)
				maxv = j - minv;
			if (j < minv)
				minv = j;
		} {
			int j = Integer.parseInt(reader.readLine());
			if (maxv < j - minv)
				maxv = j - minv;
			if (j < minv)
				minv = j;
		} int j = Integer.parseInt(reader.readLine()); j Integer.parseInt(reader.readLine()) Integer.parseInt Integer reader.readLine() reader.readLine reader if (maxv < j - minv)
				maxv = j - minv; maxv < j - minv maxv j - minv j minv maxv = j - minv maxv j - minv j minv if (j < minv)
				minv = j; j < minv j minv minv = j minv j System.out.println(maxv) System.out.println System.out System System.out maxv String[] args args public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int minv = Integer.MAX_VALUE;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int j = Integer.parseInt(reader.readLine());
			if (maxv < j - minv)
				maxv = j - minv;
			if (j < minv)
				minv = j;
		}
		System.out.println(maxv);
	}
} public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int minv = Integer.MAX_VALUE;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int j = Integer.parseInt(reader.readLine());
			if (maxv < j - minv)
				maxv = j - minv;
			if (j < minv)
				minv = j;
		}
		System.out.println(maxv);
	}
} 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 reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int minv = Integer.MAX_VALUE;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int j = Integer.parseInt(reader.readLine());
			if (maxv < j - minv)
				maxv = j - minv;
			if (j < minv)
				minv = j;
		}
		System.out.println(maxv);
	}
}