import java.util.Scanner;

public class Main {

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

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

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

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

public class Main {

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