import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next()); // ?¨?????????°

		int minv = 0, maxv = Integer.MIN_VALUE, r;

		minv = Integer.parseInt(sc.next());

		for (int i = 1; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			maxv = Integer.max(maxv, a - minv);
			minv = Integer.min(a, minv);
		}
		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 = Integer.parseInt(sc.next()); // ?¨?????????°

		int minv = 0, maxv = Integer.MIN_VALUE, r;

		minv = Integer.parseInt(sc.next());

		for (int i = 1; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			maxv = Integer.max(maxv, a - minv);
			minv = Integer.min(a, minv);
		}
		System.out.println(maxv);

	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next()); // ?¨?????????°

		int minv = 0, maxv = Integer.MIN_VALUE, r;

		minv = Integer.parseInt(sc.next());

		for (int i = 1; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			maxv = Integer.max(maxv, a - minv);
			minv = Integer.min(a, minv);
		}
		System.out.println(maxv);

	} main {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next()); // ?¨?????????°

		int minv = 0, maxv = Integer.MIN_VALUE, r;

		minv = Integer.parseInt(sc.next());

		for (int i = 1; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			maxv = Integer.max(maxv, a - minv);
			minv = Integer.min(a, minv);
		}
		System.out.println(maxv);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int minv = 0 minv 0 maxv = Integer.MIN_VALUE maxv Integer.MIN_VALUE Integer Integer.MIN_VALUE r; r minv = Integer.parseInt(sc.next()) minv Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for (int i = 1; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			maxv = Integer.max(maxv, a - minv);
			minv = Integer.min(a, minv);
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			int a = Integer.parseInt(sc.next());
			maxv = Integer.max(maxv, a - minv);
			minv = Integer.min(a, minv);
		} {
			int a = Integer.parseInt(sc.next());
			maxv = Integer.max(maxv, a - minv);
			minv = Integer.min(a, minv);
		} int a = Integer.parseInt(sc.next()); a Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc maxv = Integer.max(maxv, a - minv) maxv Integer.max(maxv, a - minv) Integer.max Integer maxv a - minv a minv minv = Integer.min(a, minv) minv Integer.min(a, minv) Integer.min Integer a minv 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 = Integer.parseInt(sc.next()); // ?¨?????????°

		int minv = 0, maxv = Integer.MIN_VALUE, r;

		minv = Integer.parseInt(sc.next());

		for (int i = 1; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			maxv = Integer.max(maxv, a - minv);
			minv = Integer.min(a, minv);
		}
		System.out.println(maxv);

	}
} public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next()); // ?¨?????????°

		int minv = 0, maxv = Integer.MIN_VALUE, r;

		minv = Integer.parseInt(sc.next());

		for (int i = 1; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			maxv = Integer.max(maxv, a - minv);
			minv = Integer.min(a, minv);
		}
		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 = Integer.parseInt(sc.next()); // ?¨?????????°

		int minv = 0, maxv = Integer.MIN_VALUE, r;

		minv = Integer.parseInt(sc.next());

		for (int i = 1; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			maxv = Integer.max(maxv, a - minv);
			minv = Integer.min(a, minv);
		}
		System.out.println(maxv);

	}
}