

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			//?????°???????????????
			int lineNum = sc.nextInt();

			//???????????????
			int[] pliceList = new int[lineNum];
			for (int i = 0; i < pliceList.length; i++) {
				pliceList[i] = sc.nextInt();
			}

			//???????¨????(roop)
			int profit = pliceList[1] - pliceList[0];
			int minplice = pliceList[0];

			for (int i = 1; i < pliceList.length; i++) {
				//?????§???????????´??°
				profit = Math.max(pliceList[i] - minplice, profit);
				//????°????????±???????
				minplice = Math.min(pliceList[i], minplice);

			}
			//????????????
			System.out.println(profit);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}

	}

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

	public static void main(String[] args) {

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			//?????°???????????????
			int lineNum = sc.nextInt();

			//???????????????
			int[] pliceList = new int[lineNum];
			for (int i = 0; i < pliceList.length; i++) {
				pliceList[i] = sc.nextInt();
			}

			//???????¨????(roop)
			int profit = pliceList[1] - pliceList[0];
			int minplice = pliceList[0];

			for (int i = 1; i < pliceList.length; i++) {
				//?????§???????????´??°
				profit = Math.max(pliceList[i] - minplice, profit);
				//????°????????±???????
				minplice = Math.min(pliceList[i], minplice);

			}
			//????????????
			System.out.println(profit);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}

	}

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

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			//?????°???????????????
			int lineNum = sc.nextInt();

			//???????????????
			int[] pliceList = new int[lineNum];
			for (int i = 0; i < pliceList.length; i++) {
				pliceList[i] = sc.nextInt();
			}

			//???????¨????(roop)
			int profit = pliceList[1] - pliceList[0];
			int minplice = pliceList[0];

			for (int i = 1; i < pliceList.length; i++) {
				//?????§???????????´??°
				profit = Math.max(pliceList[i] - minplice, profit);
				//????°????????±???????
				minplice = Math.min(pliceList[i], minplice);

			}
			//????????????
			System.out.println(profit);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}

	} main {

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			//?????°???????????????
			int lineNum = sc.nextInt();

			//???????????????
			int[] pliceList = new int[lineNum];
			for (int i = 0; i < pliceList.length; i++) {
				pliceList[i] = sc.nextInt();
			}

			//???????¨????(roop)
			int profit = pliceList[1] - pliceList[0];
			int minplice = pliceList[0];

			for (int i = 1; i < pliceList.length; i++) {
				//?????§???????????´??°
				profit = Math.max(pliceList[i] - minplice, profit);
				//????°????????±???????
				minplice = Math.min(pliceList[i], minplice);

			}
			//????????????
			System.out.println(profit);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}

	} Scanner sc = null; sc null try {
			sc = new Scanner(System.in);
			//?????°???????????????
			int lineNum = sc.nextInt();

			//???????????????
			int[] pliceList = new int[lineNum];
			for (int i = 0; i < pliceList.length; i++) {
				pliceList[i] = sc.nextInt();
			}

			//???????¨????(roop)
			int profit = pliceList[1] - pliceList[0];
			int minplice = pliceList[0];

			for (int i = 1; i < pliceList.length; i++) {
				//?????§???????????´??°
				profit = Math.max(pliceList[i] - minplice, profit);
				//????°????????±???????
				minplice = Math.min(pliceList[i], minplice);

			}
			//????????????
			System.out.println(profit);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		} catch (Exception e) {
			System.out.println(e);
		} Exception e {
			System.out.println(e);
		} System.out.println(e) System.out.println System.out System System.out e {
			if (sc != null) {
				sc.close();
			}
		} if (sc != null) {
				sc.close();
			} sc != null sc null {
				sc.close();
			} sc.close() sc.close sc {
			sc = new Scanner(System.in);
			//?????°???????????????
			int lineNum = sc.nextInt();

			//???????????????
			int[] pliceList = new int[lineNum];
			for (int i = 0; i < pliceList.length; i++) {
				pliceList[i] = sc.nextInt();
			}

			//???????¨????(roop)
			int profit = pliceList[1] - pliceList[0];
			int minplice = pliceList[0];

			for (int i = 1; i < pliceList.length; i++) {
				//?????§???????????´??°
				profit = Math.max(pliceList[i] - minplice, profit);
				//????°????????±???????
				minplice = Math.min(pliceList[i], minplice);

			}
			//????????????
			System.out.println(profit);
		} sc = new Scanner(System.in) sc new Scanner(System.in) int lineNum = sc.nextInt(); lineNum sc.nextInt() sc.nextInt sc int[] pliceList = new int[lineNum]; pliceList new int[lineNum] lineNum for (int i = 0; i < pliceList.length; i++) {
				pliceList[i] = sc.nextInt();
			} int i = 0; int i = 0; i 0 i < pliceList.length i pliceList.length pliceList pliceList.length i++ i++ i {
				pliceList[i] = sc.nextInt();
			} {
				pliceList[i] = sc.nextInt();
			} pliceList[i] = sc.nextInt() pliceList[i] pliceList i sc.nextInt() sc.nextInt sc int profit = pliceList[1] - pliceList[0]; profit pliceList[1] - pliceList[0] pliceList[1] pliceList 1 pliceList[0] pliceList 0 int minplice = pliceList[0]; minplice pliceList[0] pliceList 0 for (int i = 1; i < pliceList.length; i++) {
				//?????§???????????´??°
				profit = Math.max(pliceList[i] - minplice, profit);
				//????°????????±???????
				minplice = Math.min(pliceList[i], minplice);

			} int i = 1; int i = 1; i 1 i < pliceList.length i pliceList.length pliceList pliceList.length i++ i++ i {
				//?????§???????????´??°
				profit = Math.max(pliceList[i] - minplice, profit);
				//????°????????±???????
				minplice = Math.min(pliceList[i], minplice);

			} {
				//?????§???????????´??°
				profit = Math.max(pliceList[i] - minplice, profit);
				//????°????????±???????
				minplice = Math.min(pliceList[i], minplice);

			} profit = Math.max(pliceList[i] - minplice, profit) profit Math.max(pliceList[i] - minplice, profit) Math.max Math pliceList[i] - minplice pliceList[i] pliceList i minplice profit minplice = Math.min(pliceList[i], minplice) minplice Math.min(pliceList[i], minplice) Math.min Math pliceList[i] pliceList i minplice 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) {

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			//?????°???????????????
			int lineNum = sc.nextInt();

			//???????????????
			int[] pliceList = new int[lineNum];
			for (int i = 0; i < pliceList.length; i++) {
				pliceList[i] = sc.nextInt();
			}

			//???????¨????(roop)
			int profit = pliceList[1] - pliceList[0];
			int minplice = pliceList[0];

			for (int i = 1; i < pliceList.length; i++) {
				//?????§???????????´??°
				profit = Math.max(pliceList[i] - minplice, profit);
				//????°????????±???????
				minplice = Math.min(pliceList[i], minplice);

			}
			//????????????
			System.out.println(profit);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}

	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			//?????°???????????????
			int lineNum = sc.nextInt();

			//???????????????
			int[] pliceList = new int[lineNum];
			for (int i = 0; i < pliceList.length; i++) {
				pliceList[i] = sc.nextInt();
			}

			//???????¨????(roop)
			int profit = pliceList[1] - pliceList[0];
			int minplice = pliceList[0];

			for (int i = 1; i < pliceList.length; i++) {
				//?????§???????????´??°
				profit = Math.max(pliceList[i] - minplice, profit);
				//????°????????±???????
				minplice = Math.min(pliceList[i], minplice);

			}
			//????????????
			System.out.println(profit);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}

	}

} Main


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			//?????°???????????????
			int lineNum = sc.nextInt();

			//???????????????
			int[] pliceList = new int[lineNum];
			for (int i = 0; i < pliceList.length; i++) {
				pliceList[i] = sc.nextInt();
			}

			//???????¨????(roop)
			int profit = pliceList[1] - pliceList[0];
			int minplice = pliceList[0];

			for (int i = 1; i < pliceList.length; i++) {
				//?????§???????????´??°
				profit = Math.max(pliceList[i] - minplice, profit);
				//????°????????±???????
				minplice = Math.min(pliceList[i], minplice);

			}
			//????????????
			System.out.println(profit);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}

	}

}