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

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		int n = readInt(r);
		int[] price = new int[n];
		for(int i = 0 ; i < n ; i++) price[i] = readInt(r);

		int max = -2000000000;
		int min = price[0];
		for(int x = 1 ; x < n ; x++){
			max = Math.max(max,price[x] - min);
			min = Math.min(min,price[x]);
		}

		System.out.println(max);
	}

	public static int readInt(BufferedReader r) throws Exception{
		return Integer.parseInt(r.readLine());
	}

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

	public static void main(String[] args) throws Exception {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		int n = readInt(r);
		int[] price = new int[n];
		for(int i = 0 ; i < n ; i++) price[i] = readInt(r);

		int max = -2000000000;
		int min = price[0];
		for(int x = 1 ; x < n ; x++){
			max = Math.max(max,price[x] - min);
			min = Math.min(min,price[x]);
		}

		System.out.println(max);
	}

	public static int readInt(BufferedReader r) throws Exception{
		return Integer.parseInt(r.readLine());
	}

} Main public static void main(String[] args) throws Exception {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		int n = readInt(r);
		int[] price = new int[n];
		for(int i = 0 ; i < n ; i++) price[i] = readInt(r);

		int max = -2000000000;
		int min = price[0];
		for(int x = 1 ; x < n ; x++){
			max = Math.max(max,price[x] - min);
			min = Math.min(min,price[x]);
		}

		System.out.println(max);
	} main {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		int n = readInt(r);
		int[] price = new int[n];
		for(int i = 0 ; i < n ; i++) price[i] = readInt(r);

		int max = -2000000000;
		int min = price[0];
		for(int x = 1 ; x < n ; x++){
			max = Math.max(max,price[x] - min);
			min = Math.min(min,price[x]);
		}

		System.out.println(max);
	} BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); r new BufferedReader(new InputStreamReader(System.in)) int n = readInt(r); n readInt(r) readInt r int[] price = new int[n]; price new int[n] n for(int i = 0 ; i < n ; i++) price[i] = readInt(r); int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i price[i] = readInt(r); price[i] = readInt(r) price[i] price i readInt(r) readInt r int max = -2000000000; max -2000000000 2000000000 int min = price[0]; min price[0] price 0 for(int x = 1 ; x < n ; x++){
			max = Math.max(max,price[x] - min);
			min = Math.min(min,price[x]);
		} int x = 1 ; int x = 1 ; x 1 x < n x n x++ x++ x {
			max = Math.max(max,price[x] - min);
			min = Math.min(min,price[x]);
		} {
			max = Math.max(max,price[x] - min);
			min = Math.min(min,price[x]);
		} max = Math.max(max,price[x] - min) max Math.max(max,price[x] - min) Math.max Math max price[x] - min price[x] price x min min = Math.min(min,price[x]) min Math.min(min,price[x]) Math.min Math min price[x] price x System.out.println(max) System.out.println System.out System System.out max String[] args args public static int readInt(BufferedReader r) throws Exception{
		return Integer.parseInt(r.readLine());
	} readInt {
		return Integer.parseInt(r.readLine());
	} return Integer.parseInt(r.readLine()); Integer.parseInt(r.readLine()) Integer.parseInt Integer r.readLine() r.readLine r BufferedReader r r public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		int n = readInt(r);
		int[] price = new int[n];
		for(int i = 0 ; i < n ; i++) price[i] = readInt(r);

		int max = -2000000000;
		int min = price[0];
		for(int x = 1 ; x < n ; x++){
			max = Math.max(max,price[x] - min);
			min = Math.min(min,price[x]);
		}

		System.out.println(max);
	}

	public static int readInt(BufferedReader r) throws Exception{
		return Integer.parseInt(r.readLine());
	}

} public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		int n = readInt(r);
		int[] price = new int[n];
		for(int i = 0 ; i < n ; i++) price[i] = readInt(r);

		int max = -2000000000;
		int min = price[0];
		for(int x = 1 ; x < n ; x++){
			max = Math.max(max,price[x] - min);
			min = Math.min(min,price[x]);
		}

		System.out.println(max);
	}

	public static int readInt(BufferedReader r) throws Exception{
		return Integer.parseInt(r.readLine());
	}

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		int n = readInt(r);
		int[] price = new int[n];
		for(int i = 0 ; i < n ; i++) price[i] = readInt(r);

		int max = -2000000000;
		int min = price[0];
		for(int x = 1 ; x < n ; x++){
			max = Math.max(max,price[x] - min);
			min = Math.min(min,price[x]);
		}

		System.out.println(max);
	}

	public static int readInt(BufferedReader r) throws Exception{
		return Integer.parseInt(r.readLine());
	}

}