import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();

		int x1 =sc.nextInt();
		int x2 =sc.nextInt();

		int max = x2-x1;
		int min = Math.min(x1,x2);

		for(int i=0; i<count-2; i++) {
			int price = sc.nextInt();
			max = Math.max(max, price-min);
			min = Math.min(min, price);
		}
		System.out.println(max);

	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();

		int x1 =sc.nextInt();
		int x2 =sc.nextInt();

		int max = x2-x1;
		int min = Math.min(x1,x2);

		for(int i=0; i<count-2; i++) {
			int price = sc.nextInt();
			max = Math.max(max, price-min);
			min = Math.min(min, price);
		}
		System.out.println(max);

	}

} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();

		int x1 =sc.nextInt();
		int x2 =sc.nextInt();

		int max = x2-x1;
		int min = Math.min(x1,x2);

		for(int i=0; i<count-2; i++) {
			int price = sc.nextInt();
			max = Math.max(max, price-min);
			min = Math.min(min, price);
		}
		System.out.println(max);

	} main {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();

		int x1 =sc.nextInt();
		int x2 =sc.nextInt();

		int max = x2-x1;
		int min = Math.min(x1,x2);

		for(int i=0; i<count-2; i++) {
			int price = sc.nextInt();
			max = Math.max(max, price-min);
			min = Math.min(min, price);
		}
		System.out.println(max);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int count = sc.nextInt(); count sc.nextInt() sc.nextInt sc int x1 =sc.nextInt(); x1 sc.nextInt() sc.nextInt sc int x2 =sc.nextInt(); x2 sc.nextInt() sc.nextInt sc int max = x2-x1; max x2-x1 x2 x1 int min = Math.min(x1,x2); min Math.min(x1,x2) Math.min Math x1 x2 for(int i=0; i<count-2; i++) {
			int price = sc.nextInt();
			max = Math.max(max, price-min);
			min = Math.min(min, price);
		} int i=0; int i=0; i 0 i<count-2 i count-2 count 2 i++ i++ i {
			int price = sc.nextInt();
			max = Math.max(max, price-min);
			min = Math.min(min, price);
		} {
			int price = sc.nextInt();
			max = Math.max(max, price-min);
			min = Math.min(min, price);
		} int price = sc.nextInt(); price sc.nextInt() sc.nextInt sc max = Math.max(max, price-min) max Math.max(max, price-min) Math.max Math max price-min price min min = Math.min(min, price) min Math.min(min, price) Math.min Math min price 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) throws Exception {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();

		int x1 =sc.nextInt();
		int x2 =sc.nextInt();

		int max = x2-x1;
		int min = Math.min(x1,x2);

		for(int i=0; i<count-2; i++) {
			int price = sc.nextInt();
			max = Math.max(max, price-min);
			min = Math.min(min, price);
		}
		System.out.println(max);

	}

} public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();

		int x1 =sc.nextInt();
		int x2 =sc.nextInt();

		int max = x2-x1;
		int min = Math.min(x1,x2);

		for(int i=0; i<count-2; i++) {
			int price = sc.nextInt();
			max = Math.max(max, price-min);
			min = Math.min(min, price);
		}
		System.out.println(max);

	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();

		int x1 =sc.nextInt();
		int x2 =sc.nextInt();

		int max = x2-x1;
		int min = Math.min(x1,x2);

		for(int i=0; i<count-2; i++) {
			int price = sc.nextInt();
			max = Math.max(max, price-min);
			min = Math.min(min, price);
		}
		System.out.println(max);

	}

}
