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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int max = -1000000000;
		int N = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int min = list.get(0);
		for (int i = 1; i < list.size(); i++) {
			max = Math.max(max, list.get(i) - min);
			min = Math.min(min, list.get(i));
		}
		System.out.println(max);
	}

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

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int max = -1000000000;
		int N = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int min = list.get(0);
		for (int i = 1; i < list.size(); i++) {
			max = Math.max(max, list.get(i) - min);
			min = Math.min(min, list.get(i));
		}
		System.out.println(max);
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int max = -1000000000;
		int N = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int min = list.get(0);
		for (int i = 1; i < list.size(); i++) {
			max = Math.max(max, list.get(i) - min);
			min = Math.min(min, list.get(i));
		}
		System.out.println(max);
	} main {
		Scanner scan = new Scanner(System.in);
		int max = -1000000000;
		int N = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int min = list.get(0);
		for (int i = 1; i < list.size(); i++) {
			max = Math.max(max, list.get(i) - min);
			min = Math.min(min, list.get(i));
		}
		System.out.println(max);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int max = -1000000000; max -1000000000 1000000000 int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan List<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			list.add(scan.nextInt());
		} {
			list.add(scan.nextInt());
		} list.add(scan.nextInt()) list.add list scan.nextInt() scan.nextInt scan int min = list.get(0); min list.get(0) list.get list 0 for (int i = 1; i < list.size(); i++) {
			max = Math.max(max, list.get(i) - min);
			min = Math.min(min, list.get(i));
		} int i = 1; int i = 1; i 1 i < list.size() i list.size() list.size list i++ i++ i {
			max = Math.max(max, list.get(i) - min);
			min = Math.min(min, list.get(i));
		} {
			max = Math.max(max, list.get(i) - min);
			min = Math.min(min, list.get(i));
		} max = Math.max(max, list.get(i) - min) max Math.max(max, list.get(i) - min) Math.max Math max list.get(i) - min list.get(i) list.get list i min min = Math.min(min, list.get(i)) min Math.min(min, list.get(i)) Math.min Math min list.get(i) list.get list i 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) {
		Scanner scan = new Scanner(System.in);
		int max = -1000000000;
		int N = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int min = list.get(0);
		for (int i = 1; i < list.size(); i++) {
			max = Math.max(max, list.get(i) - min);
			min = Math.min(min, list.get(i));
		}
		System.out.println(max);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int max = -1000000000;
		int N = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int min = list.get(0);
		for (int i = 1; i < list.size(); i++) {
			max = Math.max(max, list.get(i) - min);
			min = Math.min(min, list.get(i));
		}
		System.out.println(max);
	}

} Main

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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int max = -1000000000;
		int N = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int min = list.get(0);
		for (int i = 1; i < list.size(); i++) {
			max = Math.max(max, list.get(i) - min);
			min = Math.min(min, list.get(i));
		}
		System.out.println(max);
	}

}

