import java.util.Scanner;

public class Main {
	public static Scanner scan = new Scanner(System.in);
	public static int n;
	public static void main(String args[]){
		run();
	}
	static void run(){
		int n, firstPriceTmp, priceTmp;
		int minPrice, maxPrice;
		int maxBenefit, benefit;
		
		maxBenefit = -(1000000000 - 1);
		minPrice = 1000000000;
		maxPrice = 1;
		n = scan.nextInt();
		
		firstPriceTmp = scan.nextInt();
		for(int i = 1; i < n; i++){
			priceTmp = scan.nextInt();
			minPrice = Math.min(minPrice, firstPriceTmp);
			firstPriceTmp = priceTmp;
			benefit = priceTmp - minPrice;
			maxBenefit = Math.max(benefit, maxBenefit);
		}
		System.out.println(maxBenefit);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static Scanner scan = new Scanner(System.in);
	public static int n;
	public static void main(String args[]){
		run();
	}
	static void run(){
		int n, firstPriceTmp, priceTmp;
		int minPrice, maxPrice;
		int maxBenefit, benefit;
		
		maxBenefit = -(1000000000 - 1);
		minPrice = 1000000000;
		maxPrice = 1;
		n = scan.nextInt();
		
		firstPriceTmp = scan.nextInt();
		for(int i = 1; i < n; i++){
			priceTmp = scan.nextInt();
			minPrice = Math.min(minPrice, firstPriceTmp);
			firstPriceTmp = priceTmp;
			benefit = priceTmp - minPrice;
			maxBenefit = Math.max(benefit, maxBenefit);
		}
		System.out.println(maxBenefit);
	}
} Main public static Scanner scan = new Scanner(System.in); scan new Scanner(System.in) public static int n; n public static void main(String args[]){
		run();
	} main {
		run();
	} run() run String args[] args static void run(){
		int n, firstPriceTmp, priceTmp;
		int minPrice, maxPrice;
		int maxBenefit, benefit;
		
		maxBenefit = -(1000000000 - 1);
		minPrice = 1000000000;
		maxPrice = 1;
		n = scan.nextInt();
		
		firstPriceTmp = scan.nextInt();
		for(int i = 1; i < n; i++){
			priceTmp = scan.nextInt();
			minPrice = Math.min(minPrice, firstPriceTmp);
			firstPriceTmp = priceTmp;
			benefit = priceTmp - minPrice;
			maxBenefit = Math.max(benefit, maxBenefit);
		}
		System.out.println(maxBenefit);
	} run {
		int n, firstPriceTmp, priceTmp;
		int minPrice, maxPrice;
		int maxBenefit, benefit;
		
		maxBenefit = -(1000000000 - 1);
		minPrice = 1000000000;
		maxPrice = 1;
		n = scan.nextInt();
		
		firstPriceTmp = scan.nextInt();
		for(int i = 1; i < n; i++){
			priceTmp = scan.nextInt();
			minPrice = Math.min(minPrice, firstPriceTmp);
			firstPriceTmp = priceTmp;
			benefit = priceTmp - minPrice;
			maxBenefit = Math.max(benefit, maxBenefit);
		}
		System.out.println(maxBenefit);
	} int n n firstPriceTmp firstPriceTmp priceTmp; priceTmp int minPrice minPrice maxPrice; maxPrice int maxBenefit maxBenefit benefit; benefit maxBenefit = -(1000000000 - 1) maxBenefit -(1000000000 - 1) (1000000000 - 1) 1000000000 1 minPrice = 1000000000 minPrice 1000000000 maxPrice = 1 maxPrice 1 n = scan.nextInt() n scan.nextInt() scan.nextInt scan firstPriceTmp = scan.nextInt() firstPriceTmp scan.nextInt() scan.nextInt scan for(int i = 1; i < n; i++){
			priceTmp = scan.nextInt();
			minPrice = Math.min(minPrice, firstPriceTmp);
			firstPriceTmp = priceTmp;
			benefit = priceTmp - minPrice;
			maxBenefit = Math.max(benefit, maxBenefit);
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			priceTmp = scan.nextInt();
			minPrice = Math.min(minPrice, firstPriceTmp);
			firstPriceTmp = priceTmp;
			benefit = priceTmp - minPrice;
			maxBenefit = Math.max(benefit, maxBenefit);
		} {
			priceTmp = scan.nextInt();
			minPrice = Math.min(minPrice, firstPriceTmp);
			firstPriceTmp = priceTmp;
			benefit = priceTmp - minPrice;
			maxBenefit = Math.max(benefit, maxBenefit);
		} priceTmp = scan.nextInt() priceTmp scan.nextInt() scan.nextInt scan minPrice = Math.min(minPrice, firstPriceTmp) minPrice Math.min(minPrice, firstPriceTmp) Math.min Math minPrice firstPriceTmp firstPriceTmp = priceTmp firstPriceTmp priceTmp benefit = priceTmp - minPrice benefit priceTmp - minPrice priceTmp minPrice maxBenefit = Math.max(benefit, maxBenefit) maxBenefit Math.max(benefit, maxBenefit) Math.max Math benefit maxBenefit System.out.println(maxBenefit) System.out.println System.out System System.out maxBenefit public class Main {
	public static Scanner scan = new Scanner(System.in);
	public static int n;
	public static void main(String args[]){
		run();
	}
	static void run(){
		int n, firstPriceTmp, priceTmp;
		int minPrice, maxPrice;
		int maxBenefit, benefit;
		
		maxBenefit = -(1000000000 - 1);
		minPrice = 1000000000;
		maxPrice = 1;
		n = scan.nextInt();
		
		firstPriceTmp = scan.nextInt();
		for(int i = 1; i < n; i++){
			priceTmp = scan.nextInt();
			minPrice = Math.min(minPrice, firstPriceTmp);
			firstPriceTmp = priceTmp;
			benefit = priceTmp - minPrice;
			maxBenefit = Math.max(benefit, maxBenefit);
		}
		System.out.println(maxBenefit);
	}
} public class Main {
	public static Scanner scan = new Scanner(System.in);
	public static int n;
	public static void main(String args[]){
		run();
	}
	static void run(){
		int n, firstPriceTmp, priceTmp;
		int minPrice, maxPrice;
		int maxBenefit, benefit;
		
		maxBenefit = -(1000000000 - 1);
		minPrice = 1000000000;
		maxPrice = 1;
		n = scan.nextInt();
		
		firstPriceTmp = scan.nextInt();
		for(int i = 1; i < n; i++){
			priceTmp = scan.nextInt();
			minPrice = Math.min(minPrice, firstPriceTmp);
			firstPriceTmp = priceTmp;
			benefit = priceTmp - minPrice;
			maxBenefit = Math.max(benefit, maxBenefit);
		}
		System.out.println(maxBenefit);
	}
} Main
import java.util.Scanner;

public class Main {
	public static Scanner scan = new Scanner(System.in);
	public static int n;
	public static void main(String args[]){
		run();
	}
	static void run(){
		int n, firstPriceTmp, priceTmp;
		int minPrice, maxPrice;
		int maxBenefit, benefit;
		
		maxBenefit = -(1000000000 - 1);
		minPrice = 1000000000;
		maxPrice = 1;
		n = scan.nextInt();
		
		firstPriceTmp = scan.nextInt();
		for(int i = 1; i < n; i++){
			priceTmp = scan.nextInt();
			minPrice = Math.min(minPrice, firstPriceTmp);
			firstPriceTmp = priceTmp;
			benefit = priceTmp - minPrice;
			maxBenefit = Math.max(benefit, maxBenefit);
		}
		System.out.println(maxBenefit);
	}
}