import java.util.*;
class Main {
	public static void main(String...args) {
		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
	    int minValue = scan.nextInt();
		int nowValue = scan.nextInt();
		int dif = nowValue - minValue;
		minValue = Math.min(nowValue,minValue);
		
		for(int i =0; i < times -2; i ++) {
			nowValue = scan.nextInt();
			dif = Math.max(nowValue - minValue , dif);
			minValue = Math.min(nowValue,minValue);
		}
		System.out.println(dif);
	}
} import java.util.*; util.* java class Main {
	public static void main(String...args) {
		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
	    int minValue = scan.nextInt();
		int nowValue = scan.nextInt();
		int dif = nowValue - minValue;
		minValue = Math.min(nowValue,minValue);
		
		for(int i =0; i < times -2; i ++) {
			nowValue = scan.nextInt();
			dif = Math.max(nowValue - minValue , dif);
			minValue = Math.min(nowValue,minValue);
		}
		System.out.println(dif);
	}
} Main public static void main(String...args) {
		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
	    int minValue = scan.nextInt();
		int nowValue = scan.nextInt();
		int dif = nowValue - minValue;
		minValue = Math.min(nowValue,minValue);
		
		for(int i =0; i < times -2; i ++) {
			nowValue = scan.nextInt();
			dif = Math.max(nowValue - minValue , dif);
			minValue = Math.min(nowValue,minValue);
		}
		System.out.println(dif);
	} main {
		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
	    int minValue = scan.nextInt();
		int nowValue = scan.nextInt();
		int dif = nowValue - minValue;
		minValue = Math.min(nowValue,minValue);
		
		for(int i =0; i < times -2; i ++) {
			nowValue = scan.nextInt();
			dif = Math.max(nowValue - minValue , dif);
			minValue = Math.min(nowValue,minValue);
		}
		System.out.println(dif);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int times = scan.nextInt(); times scan.nextInt() scan.nextInt scan int minValue = scan.nextInt(); minValue scan.nextInt() scan.nextInt scan int nowValue = scan.nextInt(); nowValue scan.nextInt() scan.nextInt scan int dif = nowValue - minValue; dif nowValue - minValue nowValue minValue minValue = Math.min(nowValue,minValue) minValue Math.min(nowValue,minValue) Math.min Math nowValue minValue for(int i =0; i < times -2; i ++) {
			nowValue = scan.nextInt();
			dif = Math.max(nowValue - minValue , dif);
			minValue = Math.min(nowValue,minValue);
		} int i =0; int i =0; i 0 i < times -2 i times -2 times 2 i ++ i ++ i {
			nowValue = scan.nextInt();
			dif = Math.max(nowValue - minValue , dif);
			minValue = Math.min(nowValue,minValue);
		} {
			nowValue = scan.nextInt();
			dif = Math.max(nowValue - minValue , dif);
			minValue = Math.min(nowValue,minValue);
		} nowValue = scan.nextInt() nowValue scan.nextInt() scan.nextInt scan dif = Math.max(nowValue - minValue , dif) dif Math.max(nowValue - minValue , dif) Math.max Math nowValue - minValue nowValue minValue dif minValue = Math.min(nowValue,minValue) minValue Math.min(nowValue,minValue) Math.min Math nowValue minValue System.out.println(dif) System.out.println System.out System System.out dif String...args args
import java.util.*;
class Main {
	public static void main(String...args) {
		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
	    int minValue = scan.nextInt();
		int nowValue = scan.nextInt();
		int dif = nowValue - minValue;
		minValue = Math.min(nowValue,minValue);
		
		for(int i =0; i < times -2; i ++) {
			nowValue = scan.nextInt();
			dif = Math.max(nowValue - minValue , dif);
			minValue = Math.min(nowValue,minValue);
		}
		System.out.println(dif);
	}
}
