import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		int R1 = scan.nextInt();
		int R2 = scan.nextInt();

		int gap = R2 - R1;
		int min = Math.min(R1, R2);
		for (int i = 2; i < n; i++) {
			int R = scan.nextInt();
			if (R - min > gap)
				gap = R - min;
			if (R < min)
				min = R;
		}
		System.out.println(gap);
		
		scan.close();
		System.exit(0);
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		int R1 = scan.nextInt();
		int R2 = scan.nextInt();

		int gap = R2 - R1;
		int min = Math.min(R1, R2);
		for (int i = 2; i < n; i++) {
			int R = scan.nextInt();
			if (R - min > gap)
				gap = R - min;
			if (R < min)
				min = R;
		}
		System.out.println(gap);
		
		scan.close();
		System.exit(0);
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		int R1 = scan.nextInt();
		int R2 = scan.nextInt();

		int gap = R2 - R1;
		int min = Math.min(R1, R2);
		for (int i = 2; i < n; i++) {
			int R = scan.nextInt();
			if (R - min > gap)
				gap = R - min;
			if (R < min)
				min = R;
		}
		System.out.println(gap);
		
		scan.close();
		System.exit(0);
	} main {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		int R1 = scan.nextInt();
		int R2 = scan.nextInt();

		int gap = R2 - R1;
		int min = Math.min(R1, R2);
		for (int i = 2; i < n; i++) {
			int R = scan.nextInt();
			if (R - min > gap)
				gap = R - min;
			if (R < min)
				min = R;
		}
		System.out.println(gap);
		
		scan.close();
		System.exit(0);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int R1 = scan.nextInt(); R1 scan.nextInt() scan.nextInt scan int R2 = scan.nextInt(); R2 scan.nextInt() scan.nextInt scan int gap = R2 - R1; gap R2 - R1 R2 R1 int min = Math.min(R1, R2); min Math.min(R1, R2) Math.min Math R1 R2 for (int i = 2; i < n; i++) {
			int R = scan.nextInt();
			if (R - min > gap)
				gap = R - min;
			if (R < min)
				min = R;
		} int i = 2; int i = 2; i 2 i < n i n i++ i++ i {
			int R = scan.nextInt();
			if (R - min > gap)
				gap = R - min;
			if (R < min)
				min = R;
		} {
			int R = scan.nextInt();
			if (R - min > gap)
				gap = R - min;
			if (R < min)
				min = R;
		} int R = scan.nextInt(); R scan.nextInt() scan.nextInt scan if (R - min > gap)
				gap = R - min; R - min > gap R - min R min gap gap = R - min gap R - min R min if (R < min)
				min = R; R < min R min min = R min R System.out.println(gap) System.out.println System.out System System.out gap scan.close() scan.close scan System.exit(0) System.exit System 0 String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		int R1 = scan.nextInt();
		int R2 = scan.nextInt();

		int gap = R2 - R1;
		int min = Math.min(R1, R2);
		for (int i = 2; i < n; i++) {
			int R = scan.nextInt();
			if (R - min > gap)
				gap = R - min;
			if (R < min)
				min = R;
		}
		System.out.println(gap);
		
		scan.close();
		System.exit(0);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		int R1 = scan.nextInt();
		int R2 = scan.nextInt();

		int gap = R2 - R1;
		int min = Math.min(R1, R2);
		for (int i = 2; i < n; i++) {
			int R = scan.nextInt();
			if (R - min > gap)
				gap = R - min;
			if (R < min)
				min = R;
		}
		System.out.println(gap);
		
		scan.close();
		System.exit(0);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		int R1 = scan.nextInt();
		int R2 = scan.nextInt();

		int gap = R2 - R1;
		int min = Math.min(R1, R2);
		for (int i = 2; i < n; i++) {
			int R = scan.nextInt();
			if (R - min > gap)
				gap = R - min;
			if (R < min)
				min = R;
		}
		System.out.println(gap);
		
		scan.close();
		System.exit(0);
	}

}