import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		int max = Integer.MIN_VALUE;
		Scanner san = new Scanner(System.in);
		int listCount = san.nextInt();
		int[] list = new int[listCount];
		for(int i = 0; i < listCount; i++){
			list[i] = san.nextInt();
		}
		int min = list[0];
		for(int i = 1; i < listCount; i++){
			max = Math.max(max, list[i] - min);
			min = Math.min(min, list[i]);
		}
		System.out.println(max);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		int max = Integer.MIN_VALUE;
		Scanner san = new Scanner(System.in);
		int listCount = san.nextInt();
		int[] list = new int[listCount];
		for(int i = 0; i < listCount; i++){
			list[i] = san.nextInt();
		}
		int min = list[0];
		for(int i = 1; i < listCount; i++){
			max = Math.max(max, list[i] - min);
			min = Math.min(min, list[i]);
		}
		System.out.println(max);
	}
} Main public static void main(String[] args){
		int max = Integer.MIN_VALUE;
		Scanner san = new Scanner(System.in);
		int listCount = san.nextInt();
		int[] list = new int[listCount];
		for(int i = 0; i < listCount; i++){
			list[i] = san.nextInt();
		}
		int min = list[0];
		for(int i = 1; i < listCount; i++){
			max = Math.max(max, list[i] - min);
			min = Math.min(min, list[i]);
		}
		System.out.println(max);
	} main {
		int max = Integer.MIN_VALUE;
		Scanner san = new Scanner(System.in);
		int listCount = san.nextInt();
		int[] list = new int[listCount];
		for(int i = 0; i < listCount; i++){
			list[i] = san.nextInt();
		}
		int min = list[0];
		for(int i = 1; i < listCount; i++){
			max = Math.max(max, list[i] - min);
			min = Math.min(min, list[i]);
		}
		System.out.println(max);
	} int max = Integer.MIN_VALUE; max Integer.MIN_VALUE Integer Integer.MIN_VALUE Scanner san = new Scanner(System.in); san new Scanner(System.in) int listCount = san.nextInt(); listCount san.nextInt() san.nextInt san int[] list = new int[listCount]; list new int[listCount] listCount for(int i = 0; i < listCount; i++){
			list[i] = san.nextInt();
		} int i = 0; int i = 0; i 0 i < listCount i listCount i++ i++ i {
			list[i] = san.nextInt();
		} {
			list[i] = san.nextInt();
		} list[i] = san.nextInt() list[i] list i san.nextInt() san.nextInt san int min = list[0]; min list[0] list 0 for(int i = 1; i < listCount; i++){
			max = Math.max(max, list[i] - min);
			min = Math.min(min, list[i]);
		} int i = 1; int i = 1; i 1 i < listCount i listCount i++ i++ i {
			max = Math.max(max, list[i] - min);
			min = Math.min(min, list[i]);
		} {
			max = Math.max(max, list[i] - min);
			min = Math.min(min, list[i]);
		} max = Math.max(max, list[i] - min) max Math.max(max, list[i] - min) Math.max Math max list[i] - min list[i] list i min min = Math.min(min, list[i]) min Math.min(min, list[i]) Math.min Math min list[i] list 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){
		int max = Integer.MIN_VALUE;
		Scanner san = new Scanner(System.in);
		int listCount = san.nextInt();
		int[] list = new int[listCount];
		for(int i = 0; i < listCount; i++){
			list[i] = san.nextInt();
		}
		int min = list[0];
		for(int i = 1; i < listCount; i++){
			max = Math.max(max, list[i] - min);
			min = Math.min(min, list[i]);
		}
		System.out.println(max);
	}
} public class Main {
	public static void main(String[] args){
		int max = Integer.MIN_VALUE;
		Scanner san = new Scanner(System.in);
		int listCount = san.nextInt();
		int[] list = new int[listCount];
		for(int i = 0; i < listCount; i++){
			list[i] = san.nextInt();
		}
		int min = list[0];
		for(int i = 1; i < listCount; i++){
			max = Math.max(max, list[i] - min);
			min = Math.min(min, list[i]);
		}
		System.out.println(max);
	}
} Main
import java.util.Scanner;


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