import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int Ri = sc.nextInt();
		int Rj = 1;
		int minv = Ri; 					// Rjより前の最小値
		int maxv = Integer.MIN_VALUE;	// 差の最大値

		for (int i = 1; i < n; i++) {
			Rj = sc.nextInt();
			maxv = Math.max(Rj - minv, maxv);
			minv = Math.min(minv, Rj);
		}

		System.out.println(maxv);

	}

}
 import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int Ri = sc.nextInt();
		int Rj = 1;
		int minv = Ri; 					// Rjより前の最小値
		int maxv = Integer.MIN_VALUE;	// 差の最大値

		for (int i = 1; i < n; i++) {
			Rj = sc.nextInt();
			maxv = Math.max(Rj - minv, maxv);
			minv = Math.min(minv, Rj);
		}

		System.out.println(maxv);

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int Ri = sc.nextInt();
		int Rj = 1;
		int minv = Ri; 					// Rjより前の最小値
		int maxv = Integer.MIN_VALUE;	// 差の最大値

		for (int i = 1; i < n; i++) {
			Rj = sc.nextInt();
			maxv = Math.max(Rj - minv, maxv);
			minv = Math.min(minv, Rj);
		}

		System.out.println(maxv);

	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int Ri = sc.nextInt();
		int Rj = 1;
		int minv = Ri; 					// Rjより前の最小値
		int maxv = Integer.MIN_VALUE;	// 差の最大値

		for (int i = 1; i < n; i++) {
			Rj = sc.nextInt();
			maxv = Math.max(Rj - minv, maxv);
			minv = Math.min(minv, Rj);
		}

		System.out.println(maxv);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int Ri = sc.nextInt(); Ri sc.nextInt() sc.nextInt sc int Rj = 1; Rj 1 int minv = Ri; minv Ri int maxv = Integer.MIN_VALUE; maxv Integer.MIN_VALUE Integer Integer.MIN_VALUE for (int i = 1; i < n; i++) {
			Rj = sc.nextInt();
			maxv = Math.max(Rj - minv, maxv);
			minv = Math.min(minv, Rj);
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			Rj = sc.nextInt();
			maxv = Math.max(Rj - minv, maxv);
			minv = Math.min(minv, Rj);
		} {
			Rj = sc.nextInt();
			maxv = Math.max(Rj - minv, maxv);
			minv = Math.min(minv, Rj);
		} Rj = sc.nextInt() Rj sc.nextInt() sc.nextInt sc maxv = Math.max(Rj - minv, maxv) maxv Math.max(Rj - minv, maxv) Math.max Math Rj - minv Rj minv maxv minv = Math.min(minv, Rj) minv Math.min(minv, Rj) Math.min Math minv Rj 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) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int Ri = sc.nextInt();
		int Rj = 1;
		int minv = Ri; 					// Rjより前の最小値
		int maxv = Integer.MIN_VALUE;	// 差の最大値

		for (int i = 1; i < n; i++) {
			Rj = sc.nextInt();
			maxv = Math.max(Rj - minv, maxv);
			minv = Math.min(minv, Rj);
		}

		System.out.println(maxv);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int Ri = sc.nextInt();
		int Rj = 1;
		int minv = Ri; 					// Rjより前の最小値
		int maxv = Integer.MIN_VALUE;	// 差の最大値

		for (int i = 1; i < n; i++) {
			Rj = sc.nextInt();
			maxv = Math.max(Rj - minv, maxv);
			minv = Math.min(minv, Rj);
		}

		System.out.println(maxv);

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int Ri = sc.nextInt();
		int Rj = 1;
		int minv = Ri; 					// Rjより前の最小値
		int maxv = Integer.MIN_VALUE;	// 差の最大値

		for (int i = 1; i < n; i++) {
			Rj = sc.nextInt();
			maxv = Math.max(Rj - minv, maxv);
			minv = Math.min(minv, Rj);
		}

		System.out.println(maxv);

	}

}

