import java.io.IOException;
import java.util.*;

public class Main {


	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int sizeOfList = sc.nextInt();
		List<Long> values = new ArrayList<Long>();

		long biggest = -(2000000000-1);
		for (int i = 0; i < sizeOfList; i++) {
			values.add(sc.nextLong());
		}
		long min = values.get(0);
		for (int i = 1; i < values.size(); i++) {
			long diff = values.get(i) - min;
			if (biggest < diff) {
				biggest = diff;
			}
			if (values.get(i) < min) {
				min = values.get(i);
			}
		}

		System.out.println(biggest);
	}
} import java.io.IOException; IOException java.io import java.util.*; util.* java public class Main {


	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int sizeOfList = sc.nextInt();
		List<Long> values = new ArrayList<Long>();

		long biggest = -(2000000000-1);
		for (int i = 0; i < sizeOfList; i++) {
			values.add(sc.nextLong());
		}
		long min = values.get(0);
		for (int i = 1; i < values.size(); i++) {
			long diff = values.get(i) - min;
			if (biggest < diff) {
				biggest = diff;
			}
			if (values.get(i) < min) {
				min = values.get(i);
			}
		}

		System.out.println(biggest);
	}
} Main public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int sizeOfList = sc.nextInt();
		List<Long> values = new ArrayList<Long>();

		long biggest = -(2000000000-1);
		for (int i = 0; i < sizeOfList; i++) {
			values.add(sc.nextLong());
		}
		long min = values.get(0);
		for (int i = 1; i < values.size(); i++) {
			long diff = values.get(i) - min;
			if (biggest < diff) {
				biggest = diff;
			}
			if (values.get(i) < min) {
				min = values.get(i);
			}
		}

		System.out.println(biggest);
	} main {

		Scanner sc = new Scanner(System.in);
		int sizeOfList = sc.nextInt();
		List<Long> values = new ArrayList<Long>();

		long biggest = -(2000000000-1);
		for (int i = 0; i < sizeOfList; i++) {
			values.add(sc.nextLong());
		}
		long min = values.get(0);
		for (int i = 1; i < values.size(); i++) {
			long diff = values.get(i) - min;
			if (biggest < diff) {
				biggest = diff;
			}
			if (values.get(i) < min) {
				min = values.get(i);
			}
		}

		System.out.println(biggest);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int sizeOfList = sc.nextInt(); sizeOfList sc.nextInt() sc.nextInt sc List<Long> values = new ArrayList<Long>(); values new ArrayList<Long>() long biggest = -(2000000000-1); biggest -(2000000000-1) (2000000000-1) 2000000000 1 for (int i = 0; i < sizeOfList; i++) {
			values.add(sc.nextLong());
		} int i = 0; int i = 0; i 0 i < sizeOfList i sizeOfList i++ i++ i {
			values.add(sc.nextLong());
		} {
			values.add(sc.nextLong());
		} values.add(sc.nextLong()) values.add values sc.nextLong() sc.nextLong sc long min = values.get(0); min values.get(0) values.get values 0 for (int i = 1; i < values.size(); i++) {
			long diff = values.get(i) - min;
			if (biggest < diff) {
				biggest = diff;
			}
			if (values.get(i) < min) {
				min = values.get(i);
			}
		} int i = 1; int i = 1; i 1 i < values.size() i values.size() values.size values i++ i++ i {
			long diff = values.get(i) - min;
			if (biggest < diff) {
				biggest = diff;
			}
			if (values.get(i) < min) {
				min = values.get(i);
			}
		} {
			long diff = values.get(i) - min;
			if (biggest < diff) {
				biggest = diff;
			}
			if (values.get(i) < min) {
				min = values.get(i);
			}
		} long diff = values.get(i) - min; diff values.get(i) - min values.get(i) values.get values i min if (biggest < diff) {
				biggest = diff;
			} biggest < diff biggest diff {
				biggest = diff;
			} biggest = diff biggest diff if (values.get(i) < min) {
				min = values.get(i);
			} values.get(i) < min values.get(i) values.get values i min {
				min = values.get(i);
			} min = values.get(i) min values.get(i) values.get values i System.out.println(biggest) System.out.println System.out System System.out biggest String[] args args public class Main {


	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int sizeOfList = sc.nextInt();
		List<Long> values = new ArrayList<Long>();

		long biggest = -(2000000000-1);
		for (int i = 0; i < sizeOfList; i++) {
			values.add(sc.nextLong());
		}
		long min = values.get(0);
		for (int i = 1; i < values.size(); i++) {
			long diff = values.get(i) - min;
			if (biggest < diff) {
				biggest = diff;
			}
			if (values.get(i) < min) {
				min = values.get(i);
			}
		}

		System.out.println(biggest);
	}
} public class Main {


	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int sizeOfList = sc.nextInt();
		List<Long> values = new ArrayList<Long>();

		long biggest = -(2000000000-1);
		for (int i = 0; i < sizeOfList; i++) {
			values.add(sc.nextLong());
		}
		long min = values.get(0);
		for (int i = 1; i < values.size(); i++) {
			long diff = values.get(i) - min;
			if (biggest < diff) {
				biggest = diff;
			}
			if (values.get(i) < min) {
				min = values.get(i);
			}
		}

		System.out.println(biggest);
	}
} Main
import java.io.IOException;
import java.util.*;

public class Main {


	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int sizeOfList = sc.nextInt();
		List<Long> values = new ArrayList<Long>();

		long biggest = -(2000000000-1);
		for (int i = 0; i < sizeOfList; i++) {
			values.add(sc.nextLong());
		}
		long min = values.get(0);
		for (int i = 1; i < values.size(); i++) {
			long diff = values.get(i) - min;
			if (biggest < diff) {
				biggest = diff;
			}
			if (values.get(i) < min) {
				min = values.get(i);
			}
		}

		System.out.println(biggest);
	}
}