import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int count = scanner.nextInt();
		int price = scanner.nextInt();
		int changedPrice = scanner.nextInt();
		int profit = changedPrice - price;

		if (price > changedPrice) {
			price = changedPrice;
		}

		for (int i = 0; i < count - 2; i++) {
			changedPrice = scanner.nextInt();
			if (profit < (changedPrice - price)) {
				profit = changedPrice - price;
			}
			if (changedPrice < price) {
				price = changedPrice;
			}
		}
		System.out.println(profit);
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int count = scanner.nextInt();
		int price = scanner.nextInt();
		int changedPrice = scanner.nextInt();
		int profit = changedPrice - price;

		if (price > changedPrice) {
			price = changedPrice;
		}

		for (int i = 0; i < count - 2; i++) {
			changedPrice = scanner.nextInt();
			if (profit < (changedPrice - price)) {
				profit = changedPrice - price;
			}
			if (changedPrice < price) {
				price = changedPrice;
			}
		}
		System.out.println(profit);
	}
} Main public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int count = scanner.nextInt();
		int price = scanner.nextInt();
		int changedPrice = scanner.nextInt();
		int profit = changedPrice - price;

		if (price > changedPrice) {
			price = changedPrice;
		}

		for (int i = 0; i < count - 2; i++) {
			changedPrice = scanner.nextInt();
			if (profit < (changedPrice - price)) {
				profit = changedPrice - price;
			}
			if (changedPrice < price) {
				price = changedPrice;
			}
		}
		System.out.println(profit);
	} main {

		Scanner scanner = new Scanner(System.in);
		int count = scanner.nextInt();
		int price = scanner.nextInt();
		int changedPrice = scanner.nextInt();
		int profit = changedPrice - price;

		if (price > changedPrice) {
			price = changedPrice;
		}

		for (int i = 0; i < count - 2; i++) {
			changedPrice = scanner.nextInt();
			if (profit < (changedPrice - price)) {
				profit = changedPrice - price;
			}
			if (changedPrice < price) {
				price = changedPrice;
			}
		}
		System.out.println(profit);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int count = scanner.nextInt(); count scanner.nextInt() scanner.nextInt scanner int price = scanner.nextInt(); price scanner.nextInt() scanner.nextInt scanner int changedPrice = scanner.nextInt(); changedPrice scanner.nextInt() scanner.nextInt scanner int profit = changedPrice - price; profit changedPrice - price changedPrice price if (price > changedPrice) {
			price = changedPrice;
		} price > changedPrice price changedPrice {
			price = changedPrice;
		} price = changedPrice price changedPrice for (int i = 0; i < count - 2; i++) {
			changedPrice = scanner.nextInt();
			if (profit < (changedPrice - price)) {
				profit = changedPrice - price;
			}
			if (changedPrice < price) {
				price = changedPrice;
			}
		} int i = 0; int i = 0; i 0 i < count - 2 i count - 2 count 2 i++ i++ i {
			changedPrice = scanner.nextInt();
			if (profit < (changedPrice - price)) {
				profit = changedPrice - price;
			}
			if (changedPrice < price) {
				price = changedPrice;
			}
		} {
			changedPrice = scanner.nextInt();
			if (profit < (changedPrice - price)) {
				profit = changedPrice - price;
			}
			if (changedPrice < price) {
				price = changedPrice;
			}
		} changedPrice = scanner.nextInt() changedPrice scanner.nextInt() scanner.nextInt scanner if (profit < (changedPrice - price)) {
				profit = changedPrice - price;
			} profit < (changedPrice - price) profit (changedPrice - price) changedPrice price {
				profit = changedPrice - price;
			} profit = changedPrice - price profit changedPrice - price changedPrice price if (changedPrice < price) {
				price = changedPrice;
			} changedPrice < price changedPrice price {
				price = changedPrice;
			} price = changedPrice price changedPrice System.out.println(profit) System.out.println System.out System System.out profit String[] args args
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int count = scanner.nextInt();
		int price = scanner.nextInt();
		int changedPrice = scanner.nextInt();
		int profit = changedPrice - price;

		if (price > changedPrice) {
			price = changedPrice;
		}

		for (int i = 0; i < count - 2; i++) {
			changedPrice = scanner.nextInt();
			if (profit < (changedPrice - price)) {
				profit = changedPrice - price;
			}
			if (changedPrice < price) {
				price = changedPrice;
			}
		}
		System.out.println(profit);
	}
}