import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int n = scan.nextInt();
		int maxv = Integer.MIN_VALUE;
		int minv = Integer.MAX_VALUE;
		
		for(int i = 0; i < n; i++){
			int r = scan.nextInt();
			if(i == 0){
				minv = r;
				continue;
			}
			maxv = Math.max(maxv, r - minv);
			minv = Math.min(minv, r);
		}
		System.out.printf("%d\n", maxv);
	}
} import java.util.*; util.* java public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int n = scan.nextInt();
		int maxv = Integer.MIN_VALUE;
		int minv = Integer.MAX_VALUE;
		
		for(int i = 0; i < n; i++){
			int r = scan.nextInt();
			if(i == 0){
				minv = r;
				continue;
			}
			maxv = Math.max(maxv, r - minv);
			minv = Math.min(minv, r);
		}
		System.out.printf("%d\n", maxv);
	}
} Main private static final Scanner scan = new Scanner(System.in); scan new Scanner(System.in) public static void main(String[] args){
		int n = scan.nextInt();
		int maxv = Integer.MIN_VALUE;
		int minv = Integer.MAX_VALUE;
		
		for(int i = 0; i < n; i++){
			int r = scan.nextInt();
			if(i == 0){
				minv = r;
				continue;
			}
			maxv = Math.max(maxv, r - minv);
			minv = Math.min(minv, r);
		}
		System.out.printf("%d\n", maxv);
	} main {
		int n = scan.nextInt();
		int maxv = Integer.MIN_VALUE;
		int minv = Integer.MAX_VALUE;
		
		for(int i = 0; i < n; i++){
			int r = scan.nextInt();
			if(i == 0){
				minv = r;
				continue;
			}
			maxv = Math.max(maxv, r - minv);
			minv = Math.min(minv, r);
		}
		System.out.printf("%d\n", maxv);
	} int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int maxv = Integer.MIN_VALUE; maxv Integer.MIN_VALUE Integer Integer.MIN_VALUE int minv = Integer.MAX_VALUE; minv Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i = 0; i < n; i++){
			int r = scan.nextInt();
			if(i == 0){
				minv = r;
				continue;
			}
			maxv = Math.max(maxv, r - minv);
			minv = Math.min(minv, r);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int r = scan.nextInt();
			if(i == 0){
				minv = r;
				continue;
			}
			maxv = Math.max(maxv, r - minv);
			minv = Math.min(minv, r);
		} {
			int r = scan.nextInt();
			if(i == 0){
				minv = r;
				continue;
			}
			maxv = Math.max(maxv, r - minv);
			minv = Math.min(minv, r);
		} int r = scan.nextInt(); r scan.nextInt() scan.nextInt scan if(i == 0){
				minv = r;
				continue;
			} i == 0 i 0 {
				minv = r;
				continue;
			} minv = r minv r continue; maxv = Math.max(maxv, r - minv) maxv Math.max(maxv, r - minv) Math.max Math maxv r - minv r minv minv = Math.min(minv, r) minv Math.min(minv, r) Math.min Math minv r System.out.printf("%d\n", maxv) System.out.printf System.out System System.out "%d\n" maxv String[] args args public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int n = scan.nextInt();
		int maxv = Integer.MIN_VALUE;
		int minv = Integer.MAX_VALUE;
		
		for(int i = 0; i < n; i++){
			int r = scan.nextInt();
			if(i == 0){
				minv = r;
				continue;
			}
			maxv = Math.max(maxv, r - minv);
			minv = Math.min(minv, r);
		}
		System.out.printf("%d\n", maxv);
	}
} public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int n = scan.nextInt();
		int maxv = Integer.MIN_VALUE;
		int minv = Integer.MAX_VALUE;
		
		for(int i = 0; i < n; i++){
			int r = scan.nextInt();
			if(i == 0){
				minv = r;
				continue;
			}
			maxv = Math.max(maxv, r - minv);
			minv = Math.min(minv, r);
		}
		System.out.printf("%d\n", maxv);
	}
} Main
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int n = scan.nextInt();
		int maxv = Integer.MIN_VALUE;
		int minv = Integer.MAX_VALUE;
		
		for(int i = 0; i < n; i++){
			int r = scan.nextInt();
			if(i == 0){
				minv = r;
				continue;
			}
			maxv = Math.max(maxv, r - minv);
			minv = Math.min(minv, r);
		}
		System.out.printf("%d\n", maxv);
	}
}