import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	static int[] memo = new int[45];
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<Integer> diff = new ArrayList<Integer>();
		
		int n = in.nextInt();
		int min = in.nextInt();
		for (int i = 1; i < n; i++) {
			int val = in.nextInt();
			diff.add(val-min);
			if (min > val) min=val;
		}
		Collections.sort(diff, Comparator.reverseOrder());
		System.out.println(diff.get(0));
	}
}
 import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Comparator; Comparator java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	
	static int[] memo = new int[45];
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<Integer> diff = new ArrayList<Integer>();
		
		int n = in.nextInt();
		int min = in.nextInt();
		for (int i = 1; i < n; i++) {
			int val = in.nextInt();
			diff.add(val-min);
			if (min > val) min=val;
		}
		Collections.sort(diff, Comparator.reverseOrder());
		System.out.println(diff.get(0));
	}
} Main static int[] memo = new int[45]; memo new int[45] 45 public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<Integer> diff = new ArrayList<Integer>();
		
		int n = in.nextInt();
		int min = in.nextInt();
		for (int i = 1; i < n; i++) {
			int val = in.nextInt();
			diff.add(val-min);
			if (min > val) min=val;
		}
		Collections.sort(diff, Comparator.reverseOrder());
		System.out.println(diff.get(0));
	} main {
		Scanner in = new Scanner(System.in);
		List<Integer> diff = new ArrayList<Integer>();
		
		int n = in.nextInt();
		int min = in.nextInt();
		for (int i = 1; i < n; i++) {
			int val = in.nextInt();
			diff.add(val-min);
			if (min > val) min=val;
		}
		Collections.sort(diff, Comparator.reverseOrder());
		System.out.println(diff.get(0));
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) List<Integer> diff = new ArrayList<Integer>(); diff new ArrayList<Integer>() int n = in.nextInt(); n in.nextInt() in.nextInt in int min = in.nextInt(); min in.nextInt() in.nextInt in for (int i = 1; i < n; i++) {
			int val = in.nextInt();
			diff.add(val-min);
			if (min > val) min=val;
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			int val = in.nextInt();
			diff.add(val-min);
			if (min > val) min=val;
		} {
			int val = in.nextInt();
			diff.add(val-min);
			if (min > val) min=val;
		} int val = in.nextInt(); val in.nextInt() in.nextInt in diff.add(val-min) diff.add diff val-min val min if (min > val) min=val; min > val min val min=val min val Collections.sort(diff, Comparator.reverseOrder()) Collections.sort Collections diff Comparator.reverseOrder() Comparator.reverseOrder Comparator System.out.println(diff.get(0)) System.out.println System.out System System.out diff.get(0) diff.get diff 0 String[] args args public class Main {
	
	static int[] memo = new int[45];
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<Integer> diff = new ArrayList<Integer>();
		
		int n = in.nextInt();
		int min = in.nextInt();
		for (int i = 1; i < n; i++) {
			int val = in.nextInt();
			diff.add(val-min);
			if (min > val) min=val;
		}
		Collections.sort(diff, Comparator.reverseOrder());
		System.out.println(diff.get(0));
	}
} public class Main {
	
	static int[] memo = new int[45];
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<Integer> diff = new ArrayList<Integer>();
		
		int n = in.nextInt();
		int min = in.nextInt();
		for (int i = 1; i < n; i++) {
			int val = in.nextInt();
			diff.add(val-min);
			if (min > val) min=val;
		}
		Collections.sort(diff, Comparator.reverseOrder());
		System.out.println(diff.get(0));
	}
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	static int[] memo = new int[45];
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<Integer> diff = new ArrayList<Integer>();
		
		int n = in.nextInt();
		int min = in.nextInt();
		for (int i = 1; i < n; i++) {
			int val = in.nextInt();
			diff.add(val-min);
			if (min > val) min=val;
		}
		Collections.sort(diff, Comparator.reverseOrder());
		System.out.println(diff.get(0));
	}
}

