import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		List<Integer> num = new ArrayList<>();
		List<Integer> min = new ArrayList<>();
		int n, m = Integer.MAX_VALUE, M = Integer.MIN_VALUE;

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int tmp;

		for (int i = 0; i < n; i++) {
			tmp = sc.nextInt();
			if (tmp < m) {
				m = tmp;
			}
			num.add(tmp);
			min.add(m);
		}
		sc.close();

		for (int i = 1; i < n; i++) {
			tmp = num.get(i) - min.get(i - 1);
			if (tmp > M) {
				M = tmp;
			}
		}
		System.out.println(M);
	}
}
 import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		List<Integer> num = new ArrayList<>();
		List<Integer> min = new ArrayList<>();
		int n, m = Integer.MAX_VALUE, M = Integer.MIN_VALUE;

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int tmp;

		for (int i = 0; i < n; i++) {
			tmp = sc.nextInt();
			if (tmp < m) {
				m = tmp;
			}
			num.add(tmp);
			min.add(m);
		}
		sc.close();

		for (int i = 1; i < n; i++) {
			tmp = num.get(i) - min.get(i - 1);
			if (tmp > M) {
				M = tmp;
			}
		}
		System.out.println(M);
	}
} Main public static void main(String[] args) {
		List<Integer> num = new ArrayList<>();
		List<Integer> min = new ArrayList<>();
		int n, m = Integer.MAX_VALUE, M = Integer.MIN_VALUE;

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int tmp;

		for (int i = 0; i < n; i++) {
			tmp = sc.nextInt();
			if (tmp < m) {
				m = tmp;
			}
			num.add(tmp);
			min.add(m);
		}
		sc.close();

		for (int i = 1; i < n; i++) {
			tmp = num.get(i) - min.get(i - 1);
			if (tmp > M) {
				M = tmp;
			}
		}
		System.out.println(M);
	} main {
		List<Integer> num = new ArrayList<>();
		List<Integer> min = new ArrayList<>();
		int n, m = Integer.MAX_VALUE, M = Integer.MIN_VALUE;

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int tmp;

		for (int i = 0; i < n; i++) {
			tmp = sc.nextInt();
			if (tmp < m) {
				m = tmp;
			}
			num.add(tmp);
			min.add(m);
		}
		sc.close();

		for (int i = 1; i < n; i++) {
			tmp = num.get(i) - min.get(i - 1);
			if (tmp > M) {
				M = tmp;
			}
		}
		System.out.println(M);
	} List<Integer> num = new ArrayList<>(); num new ArrayList<>() List<Integer> min = new ArrayList<>(); min new ArrayList<>() int n n m = Integer.MAX_VALUE m Integer.MAX_VALUE Integer Integer.MAX_VALUE M = Integer.MIN_VALUE; M Integer.MIN_VALUE Integer Integer.MIN_VALUE Scanner sc = new Scanner(System.in); sc new Scanner(System.in) n = sc.nextInt() n sc.nextInt() sc.nextInt sc int tmp; tmp for (int i = 0; i < n; i++) {
			tmp = sc.nextInt();
			if (tmp < m) {
				m = tmp;
			}
			num.add(tmp);
			min.add(m);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			tmp = sc.nextInt();
			if (tmp < m) {
				m = tmp;
			}
			num.add(tmp);
			min.add(m);
		} {
			tmp = sc.nextInt();
			if (tmp < m) {
				m = tmp;
			}
			num.add(tmp);
			min.add(m);
		} tmp = sc.nextInt() tmp sc.nextInt() sc.nextInt sc if (tmp < m) {
				m = tmp;
			} tmp < m tmp m {
				m = tmp;
			} m = tmp m tmp num.add(tmp) num.add num tmp min.add(m) min.add min m sc.close() sc.close sc for (int i = 1; i < n; i++) {
			tmp = num.get(i) - min.get(i - 1);
			if (tmp > M) {
				M = tmp;
			}
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			tmp = num.get(i) - min.get(i - 1);
			if (tmp > M) {
				M = tmp;
			}
		} {
			tmp = num.get(i) - min.get(i - 1);
			if (tmp > M) {
				M = tmp;
			}
		} tmp = num.get(i) - min.get(i - 1) tmp num.get(i) - min.get(i - 1) num.get(i) num.get num i min.get(i - 1) min.get min i - 1 i 1 if (tmp > M) {
				M = tmp;
			} tmp > M tmp M {
				M = tmp;
			} M = tmp M tmp System.out.println(M) System.out.println System.out System System.out M String[] args args public class Main {
	public static void main(String[] args) {
		List<Integer> num = new ArrayList<>();
		List<Integer> min = new ArrayList<>();
		int n, m = Integer.MAX_VALUE, M = Integer.MIN_VALUE;

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int tmp;

		for (int i = 0; i < n; i++) {
			tmp = sc.nextInt();
			if (tmp < m) {
				m = tmp;
			}
			num.add(tmp);
			min.add(m);
		}
		sc.close();

		for (int i = 1; i < n; i++) {
			tmp = num.get(i) - min.get(i - 1);
			if (tmp > M) {
				M = tmp;
			}
		}
		System.out.println(M);
	}
} public class Main {
	public static void main(String[] args) {
		List<Integer> num = new ArrayList<>();
		List<Integer> min = new ArrayList<>();
		int n, m = Integer.MAX_VALUE, M = Integer.MIN_VALUE;

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int tmp;

		for (int i = 0; i < n; i++) {
			tmp = sc.nextInt();
			if (tmp < m) {
				m = tmp;
			}
			num.add(tmp);
			min.add(m);
		}
		sc.close();

		for (int i = 1; i < n; i++) {
			tmp = num.get(i) - min.get(i - 1);
			if (tmp > M) {
				M = tmp;
			}
		}
		System.out.println(M);
	}
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		List<Integer> num = new ArrayList<>();
		List<Integer> min = new ArrayList<>();
		int n, m = Integer.MAX_VALUE, M = Integer.MIN_VALUE;

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int tmp;

		for (int i = 0; i < n; i++) {
			tmp = sc.nextInt();
			if (tmp < m) {
				m = tmp;
			}
			num.add(tmp);
			min.add(m);
		}
		sc.close();

		for (int i = 1; i < n; i++) {
			tmp = num.get(i) - min.get(i - 1);
			if (tmp > M) {
				M = tmp;
			}
		}
		System.out.println(M);
	}
}

