import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	int n;
	int[] R;
	int max,min;
	
	public void input() {
		n = sc.nextInt();
		R = new int[n];
		for(int i=0; i<n; i++) R[i] = sc.nextInt();
	}
	
	public void compute() {
		min = R[0];
		max = Integer.MIN_VALUE;
		for(int i=1; i<n; i++) {
			max = Math.max(max, R[i]-min);
			min = Math.min(min, R[i]);
		}
		System.out.println(max);
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.compute();
	}
}
 import java.util.*; util.* java public class Main {
	Scanner sc = new Scanner(System.in);
	
	int n;
	int[] R;
	int max,min;
	
	public void input() {
		n = sc.nextInt();
		R = new int[n];
		for(int i=0; i<n; i++) R[i] = sc.nextInt();
	}
	
	public void compute() {
		min = R[0];
		max = Integer.MIN_VALUE;
		for(int i=1; i<n; i++) {
			max = Math.max(max, R[i]-min);
			min = Math.min(min, R[i]);
		}
		System.out.println(max);
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.compute();
	}
} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n; n int[] R; R int max max min; min public void input() {
		n = sc.nextInt();
		R = new int[n];
		for(int i=0; i<n; i++) R[i] = sc.nextInt();
	} input {
		n = sc.nextInt();
		R = new int[n];
		for(int i=0; i<n; i++) R[i] = sc.nextInt();
	} n = sc.nextInt() n sc.nextInt() sc.nextInt sc R = new int[n] R new int[n] n for(int i=0; i<n; i++) R[i] = sc.nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i R[i] = sc.nextInt(); R[i] = sc.nextInt() R[i] R i sc.nextInt() sc.nextInt sc public void compute() {
		min = R[0];
		max = Integer.MIN_VALUE;
		for(int i=1; i<n; i++) {
			max = Math.max(max, R[i]-min);
			min = Math.min(min, R[i]);
		}
		System.out.println(max);
	} compute {
		min = R[0];
		max = Integer.MIN_VALUE;
		for(int i=1; i<n; i++) {
			max = Math.max(max, R[i]-min);
			min = Math.min(min, R[i]);
		}
		System.out.println(max);
	} min = R[0] min R[0] R 0 max = Integer.MIN_VALUE max Integer.MIN_VALUE Integer Integer.MIN_VALUE for(int i=1; i<n; i++) {
			max = Math.max(max, R[i]-min);
			min = Math.min(min, R[i]);
		} int i=1; int i=1; i 1 i<n i n i++ i++ i {
			max = Math.max(max, R[i]-min);
			min = Math.min(min, R[i]);
		} {
			max = Math.max(max, R[i]-min);
			min = Math.min(min, R[i]);
		} max = Math.max(max, R[i]-min) max Math.max(max, R[i]-min) Math.max Math max R[i]-min R[i] R i min min = Math.min(min, R[i]) min Math.min(min, R[i]) Math.min Math min R[i] R i System.out.println(max) System.out.println System.out System System.out max public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.compute();
	} main {
		Main obj = new Main();
		obj.input();
		obj.compute();
	} Main obj = new Main(); obj new Main() obj.input() obj.input obj obj.compute() obj.compute obj String[] args args public class Main {
	Scanner sc = new Scanner(System.in);
	
	int n;
	int[] R;
	int max,min;
	
	public void input() {
		n = sc.nextInt();
		R = new int[n];
		for(int i=0; i<n; i++) R[i] = sc.nextInt();
	}
	
	public void compute() {
		min = R[0];
		max = Integer.MIN_VALUE;
		for(int i=1; i<n; i++) {
			max = Math.max(max, R[i]-min);
			min = Math.min(min, R[i]);
		}
		System.out.println(max);
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.compute();
	}
} public class Main {
	Scanner sc = new Scanner(System.in);
	
	int n;
	int[] R;
	int max,min;
	
	public void input() {
		n = sc.nextInt();
		R = new int[n];
		for(int i=0; i<n; i++) R[i] = sc.nextInt();
	}
	
	public void compute() {
		min = R[0];
		max = Integer.MIN_VALUE;
		for(int i=1; i<n; i++) {
			max = Math.max(max, R[i]-min);
			min = Math.min(min, R[i]);
		}
		System.out.println(max);
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.compute();
	}
} Main
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	int n;
	int[] R;
	int max,min;
	
	public void input() {
		n = sc.nextInt();
		R = new int[n];
		for(int i=0; i<n; i++) R[i] = sc.nextInt();
	}
	
	public void compute() {
		min = R[0];
		max = Integer.MIN_VALUE;
		for(int i=1; i<n; i++) {
			max = Math.max(max, R[i]-min);
			min = Math.min(min, R[i]);
		}
		System.out.println(max);
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.compute();
	}
}

