import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
	    int min = 1000000000, profit = -1000000000;
	    int getNum = scan.nextInt();
	    min = getNum;

		for(int i = 0; i < n-1; i++) {
		 getNum = scan.nextInt();

		 if(profit < getNum-min) {
				profit = getNum-min;
		}

			if(min > getNum) {
				min = getNum;
			}
		}

		System.out.println(profit);
		}
	} import java.util.Scanner; Scanner java.util public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
	    int min = 1000000000, profit = -1000000000;
	    int getNum = scan.nextInt();
	    min = getNum;

		for(int i = 0; i < n-1; i++) {
		 getNum = scan.nextInt();

		 if(profit < getNum-min) {
				profit = getNum-min;
		}

			if(min > getNum) {
				min = getNum;
			}
		}

		System.out.println(profit);
		}
	} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
	    int min = 1000000000, profit = -1000000000;
	    int getNum = scan.nextInt();
	    min = getNum;

		for(int i = 0; i < n-1; i++) {
		 getNum = scan.nextInt();

		 if(profit < getNum-min) {
				profit = getNum-min;
		}

			if(min > getNum) {
				min = getNum;
			}
		}

		System.out.println(profit);
		} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
	    int min = 1000000000, profit = -1000000000;
	    int getNum = scan.nextInt();
	    min = getNum;

		for(int i = 0; i < n-1; i++) {
		 getNum = scan.nextInt();

		 if(profit < getNum-min) {
				profit = getNum-min;
		}

			if(min > getNum) {
				min = getNum;
			}
		}

		System.out.println(profit);
		} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int min = 1000000000 min 1000000000 profit = -1000000000; profit -1000000000 1000000000 int getNum = scan.nextInt(); getNum scan.nextInt() scan.nextInt scan min = getNum min getNum for(int i = 0; i < n-1; i++) {
		 getNum = scan.nextInt();

		 if(profit < getNum-min) {
				profit = getNum-min;
		}

			if(min > getNum) {
				min = getNum;
			}
		} int i = 0; int i = 0; i 0 i < n-1 i n-1 n 1 i++ i++ i {
		 getNum = scan.nextInt();

		 if(profit < getNum-min) {
				profit = getNum-min;
		}

			if(min > getNum) {
				min = getNum;
			}
		} {
		 getNum = scan.nextInt();

		 if(profit < getNum-min) {
				profit = getNum-min;
		}

			if(min > getNum) {
				min = getNum;
			}
		} getNum = scan.nextInt() getNum scan.nextInt() scan.nextInt scan if(profit < getNum-min) {
				profit = getNum-min;
		} profit < getNum-min profit getNum-min getNum min {
				profit = getNum-min;
		} profit = getNum-min profit getNum-min getNum min if(min > getNum) {
				min = getNum;
			} min > getNum min getNum {
				min = getNum;
			} min = getNum min getNum System.out.println(profit) System.out.println System.out System System.out profit String[] args args public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
	    int min = 1000000000, profit = -1000000000;
	    int getNum = scan.nextInt();
	    min = getNum;

		for(int i = 0; i < n-1; i++) {
		 getNum = scan.nextInt();

		 if(profit < getNum-min) {
				profit = getNum-min;
		}

			if(min > getNum) {
				min = getNum;
			}
		}

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


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
	    int min = 1000000000, profit = -1000000000;
	    int getNum = scan.nextInt();
	    min = getNum;

		for(int i = 0; i < n-1; i++) {
		 getNum = scan.nextInt();

		 if(profit < getNum-min) {
				profit = getNum-min;
		}

			if(min > getNum) {
				min = getNum;
			}
		}

		System.out.println(profit);
		}
	} Main
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
	    int min = 1000000000, profit = -1000000000;
	    int getNum = scan.nextInt();
	    min = getNum;

		for(int i = 0; i < n-1; i++) {
		 getNum = scan.nextInt();

		 if(profit < getNum-min) {
				profit = getNum-min;
		}

			if(min > getNum) {
				min = getNum;
			}
		}

		System.out.println(profit);
		}
	}
