import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static final int MAX = 200000;

	public static void main(String[] args) throws IOException {

		int Nums[] = new int[MAX];

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String n = br.readLine();

		for(int i=0; i<Integer.parseInt(n); i++){
			 Nums[i] = Integer.parseInt(br.readLine());
			}


		int max = -2000000000;
		int min = Nums[0];

		for(int i=1; i<Integer.parseInt(n); i++){
			max = Math.max(max, Nums[i]-min);
			min = Math.min(min, Nums[i]);
		}

		System.out.println(max);

	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io class Main {

	public static final int MAX = 200000;

	public static void main(String[] args) throws IOException {

		int Nums[] = new int[MAX];

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String n = br.readLine();

		for(int i=0; i<Integer.parseInt(n); i++){
			 Nums[i] = Integer.parseInt(br.readLine());
			}


		int max = -2000000000;
		int min = Nums[0];

		for(int i=1; i<Integer.parseInt(n); i++){
			max = Math.max(max, Nums[i]-min);
			min = Math.min(min, Nums[i]);
		}

		System.out.println(max);

	}

} Main public static final int MAX = 200000; MAX 200000 public static void main(String[] args) throws IOException {

		int Nums[] = new int[MAX];

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String n = br.readLine();

		for(int i=0; i<Integer.parseInt(n); i++){
			 Nums[i] = Integer.parseInt(br.readLine());
			}


		int max = -2000000000;
		int min = Nums[0];

		for(int i=1; i<Integer.parseInt(n); i++){
			max = Math.max(max, Nums[i]-min);
			min = Math.min(min, Nums[i]);
		}

		System.out.println(max);

	} main {

		int Nums[] = new int[MAX];

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String n = br.readLine();

		for(int i=0; i<Integer.parseInt(n); i++){
			 Nums[i] = Integer.parseInt(br.readLine());
			}


		int max = -2000000000;
		int min = Nums[0];

		for(int i=1; i<Integer.parseInt(n); i++){
			max = Math.max(max, Nums[i]-min);
			min = Math.min(min, Nums[i]);
		}

		System.out.println(max);

	} int Nums[] = new int[MAX]; Nums new int[MAX] MAX BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String n = br.readLine(); n br.readLine() br.readLine br for(int i=0; i<Integer.parseInt(n); i++){
			 Nums[i] = Integer.parseInt(br.readLine());
			} int i=0; int i=0; i 0 i<Integer.parseInt(n) i Integer.parseInt(n) Integer.parseInt Integer n i++ i++ i {
			 Nums[i] = Integer.parseInt(br.readLine());
			} {
			 Nums[i] = Integer.parseInt(br.readLine());
			} Nums[i] = Integer.parseInt(br.readLine()) Nums[i] Nums i Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int max = -2000000000; max -2000000000 2000000000 int min = Nums[0]; min Nums[0] Nums 0 for(int i=1; i<Integer.parseInt(n); i++){
			max = Math.max(max, Nums[i]-min);
			min = Math.min(min, Nums[i]);
		} int i=1; int i=1; i 1 i<Integer.parseInt(n) i Integer.parseInt(n) Integer.parseInt Integer n i++ i++ i {
			max = Math.max(max, Nums[i]-min);
			min = Math.min(min, Nums[i]);
		} {
			max = Math.max(max, Nums[i]-min);
			min = Math.min(min, Nums[i]);
		} max = Math.max(max, Nums[i]-min) max Math.max(max, Nums[i]-min) Math.max Math max Nums[i]-min Nums[i] Nums i min min = Math.min(min, Nums[i]) min Math.min(min, Nums[i]) Math.min Math min Nums[i] Nums i System.out.println(max) System.out.println System.out System System.out max String[] args args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static final int MAX = 200000;

	public static void main(String[] args) throws IOException {

		int Nums[] = new int[MAX];

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String n = br.readLine();

		for(int i=0; i<Integer.parseInt(n); i++){
			 Nums[i] = Integer.parseInt(br.readLine());
			}


		int max = -2000000000;
		int min = Nums[0];

		for(int i=1; i<Integer.parseInt(n); i++){
			max = Math.max(max, Nums[i]-min);
			min = Math.min(min, Nums[i]);
		}

		System.out.println(max);

	}

}