import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long max_profit = -999999999;
		long prev = 1000000001;
		
		int N = sc.nextInt();
		long[] R = new long[N];
		for (int i = 0; i < N; i++) {
			R[i] = sc.nextLong();
		}
		
		for (int i = 0; i < N; i++) {
			if (prev <= R[i]) {
				continue;
			}
			for (int j = i+1; j < N; j++) {
				long tmp = R[j] - R[i];
				max_profit = Math.max(max_profit, tmp);
			}
			prev = R[i];
		}
		
		System.out.println(max_profit);
	}
} import java.util.*; util.* java class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long max_profit = -999999999;
		long prev = 1000000001;
		
		int N = sc.nextInt();
		long[] R = new long[N];
		for (int i = 0; i < N; i++) {
			R[i] = sc.nextLong();
		}
		
		for (int i = 0; i < N; i++) {
			if (prev <= R[i]) {
				continue;
			}
			for (int j = i+1; j < N; j++) {
				long tmp = R[j] - R[i];
				max_profit = Math.max(max_profit, tmp);
			}
			prev = R[i];
		}
		
		System.out.println(max_profit);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long max_profit = -999999999;
		long prev = 1000000001;
		
		int N = sc.nextInt();
		long[] R = new long[N];
		for (int i = 0; i < N; i++) {
			R[i] = sc.nextLong();
		}
		
		for (int i = 0; i < N; i++) {
			if (prev <= R[i]) {
				continue;
			}
			for (int j = i+1; j < N; j++) {
				long tmp = R[j] - R[i];
				max_profit = Math.max(max_profit, tmp);
			}
			prev = R[i];
		}
		
		System.out.println(max_profit);
	} main {
		Scanner sc = new Scanner(System.in);
		long max_profit = -999999999;
		long prev = 1000000001;
		
		int N = sc.nextInt();
		long[] R = new long[N];
		for (int i = 0; i < N; i++) {
			R[i] = sc.nextLong();
		}
		
		for (int i = 0; i < N; i++) {
			if (prev <= R[i]) {
				continue;
			}
			for (int j = i+1; j < N; j++) {
				long tmp = R[j] - R[i];
				max_profit = Math.max(max_profit, tmp);
			}
			prev = R[i];
		}
		
		System.out.println(max_profit);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long max_profit = -999999999; max_profit -999999999 999999999 long prev = 1000000001; prev 1000000001 int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long[] R = new long[N]; R new long[N] N for (int i = 0; i < N; i++) {
			R[i] = sc.nextLong();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			R[i] = sc.nextLong();
		} {
			R[i] = sc.nextLong();
		} R[i] = sc.nextLong() R[i] R i sc.nextLong() sc.nextLong sc for (int i = 0; i < N; i++) {
			if (prev <= R[i]) {
				continue;
			}
			for (int j = i+1; j < N; j++) {
				long tmp = R[j] - R[i];
				max_profit = Math.max(max_profit, tmp);
			}
			prev = R[i];
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			if (prev <= R[i]) {
				continue;
			}
			for (int j = i+1; j < N; j++) {
				long tmp = R[j] - R[i];
				max_profit = Math.max(max_profit, tmp);
			}
			prev = R[i];
		} {
			if (prev <= R[i]) {
				continue;
			}
			for (int j = i+1; j < N; j++) {
				long tmp = R[j] - R[i];
				max_profit = Math.max(max_profit, tmp);
			}
			prev = R[i];
		} if (prev <= R[i]) {
				continue;
			} prev <= R[i] prev R[i] R i {
				continue;
			} continue; for (int j = i+1; j < N; j++) {
				long tmp = R[j] - R[i];
				max_profit = Math.max(max_profit, tmp);
			} int j = i+1; int j = i+1; j i+1 i 1 j < N j N j++ j++ j {
				long tmp = R[j] - R[i];
				max_profit = Math.max(max_profit, tmp);
			} {
				long tmp = R[j] - R[i];
				max_profit = Math.max(max_profit, tmp);
			} long tmp = R[j] - R[i]; tmp R[j] - R[i] R[j] R j R[i] R i max_profit = Math.max(max_profit, tmp) max_profit Math.max(max_profit, tmp) Math.max Math max_profit tmp prev = R[i] prev R[i] R i System.out.println(max_profit) System.out.println System.out System System.out max_profit String[] args args
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long max_profit = -999999999;
		long prev = 1000000001;
		
		int N = sc.nextInt();
		long[] R = new long[N];
		for (int i = 0; i < N; i++) {
			R[i] = sc.nextLong();
		}
		
		for (int i = 0; i < N; i++) {
			if (prev <= R[i]) {
				continue;
			}
			for (int j = i+1; j < N; j++) {
				long tmp = R[j] - R[i];
				max_profit = Math.max(max_profit, tmp);
			}
			prev = R[i];
		}
		
		System.out.println(max_profit);
	}
}