public class Main {
	
	public void run(java.io.InputStream in, java.io.PrintStream out) {
		final java.util.Scanner sc = new java.util.Scanner(in);
		final int[] r = new int[sc.nextInt()];
		int max, min;
		
		for (int i = 0; i < r.length; ++i) {
			r[i] = sc.nextInt();
		}
		
		max = Integer.MIN_VALUE; min = r[0];
		for (int i = 1; i < r.length; ++i) {
			max = Math.max(max, r[i] - min);
			min = Math.min(min, r[i]);
		}
		out.println(max);
		
		sc.close();
	}

	public static void main(String[] args) {
		(new Main()).run(System.in, System.out);
	}

} public class Main {
	
	public void run(java.io.InputStream in, java.io.PrintStream out) {
		final java.util.Scanner sc = new java.util.Scanner(in);
		final int[] r = new int[sc.nextInt()];
		int max, min;
		
		for (int i = 0; i < r.length; ++i) {
			r[i] = sc.nextInt();
		}
		
		max = Integer.MIN_VALUE; min = r[0];
		for (int i = 1; i < r.length; ++i) {
			max = Math.max(max, r[i] - min);
			min = Math.min(min, r[i]);
		}
		out.println(max);
		
		sc.close();
	}

	public static void main(String[] args) {
		(new Main()).run(System.in, System.out);
	}

} Main public void run(java.io.InputStream in, java.io.PrintStream out) {
		final java.util.Scanner sc = new java.util.Scanner(in);
		final int[] r = new int[sc.nextInt()];
		int max, min;
		
		for (int i = 0; i < r.length; ++i) {
			r[i] = sc.nextInt();
		}
		
		max = Integer.MIN_VALUE; min = r[0];
		for (int i = 1; i < r.length; ++i) {
			max = Math.max(max, r[i] - min);
			min = Math.min(min, r[i]);
		}
		out.println(max);
		
		sc.close();
	} run {
		final java.util.Scanner sc = new java.util.Scanner(in);
		final int[] r = new int[sc.nextInt()];
		int max, min;
		
		for (int i = 0; i < r.length; ++i) {
			r[i] = sc.nextInt();
		}
		
		max = Integer.MIN_VALUE; min = r[0];
		for (int i = 1; i < r.length; ++i) {
			max = Math.max(max, r[i] - min);
			min = Math.min(min, r[i]);
		}
		out.println(max);
		
		sc.close();
	} final java.util.Scanner sc = new java.util.Scanner(in); sc new java.util.Scanner(in) final int[] r = new int[sc.nextInt()]; r new int[sc.nextInt()] sc.nextInt() sc.nextInt sc int max max min; min for (int i = 0; i < r.length; ++i) {
			r[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < r.length i r.length r r.length ++i ++i i {
			r[i] = sc.nextInt();
		} {
			r[i] = sc.nextInt();
		} r[i] = sc.nextInt() r[i] r i sc.nextInt() sc.nextInt sc max = Integer.MIN_VALUE max Integer.MIN_VALUE Integer Integer.MIN_VALUE min = r[0] min r[0] r 0 for (int i = 1; i < r.length; ++i) {
			max = Math.max(max, r[i] - min);
			min = Math.min(min, r[i]);
		} int i = 1; int i = 1; i 1 i < r.length i r.length r r.length ++i ++i i {
			max = Math.max(max, r[i] - min);
			min = Math.min(min, r[i]);
		} {
			max = Math.max(max, r[i] - min);
			min = Math.min(min, r[i]);
		} max = Math.max(max, r[i] - min) max Math.max(max, r[i] - min) Math.max Math max r[i] - min r[i] r i min min = Math.min(min, r[i]) min Math.min(min, r[i]) Math.min Math min r[i] r i out.println(max) out.println out max sc.close() sc.close sc java.io.InputStream in in java.io.PrintStream out out public static void main(String[] args) {
		(new Main()).run(System.in, System.out);
	} main {
		(new Main()).run(System.in, System.out);
	} (new Main()).run(System.in, System.out) (new Main()).run (new Main()) System.in System System.in System.out System System.out String[] args args public class Main {
	
	public void run(java.io.InputStream in, java.io.PrintStream out) {
		final java.util.Scanner sc = new java.util.Scanner(in);
		final int[] r = new int[sc.nextInt()];
		int max, min;
		
		for (int i = 0; i < r.length; ++i) {
			r[i] = sc.nextInt();
		}
		
		max = Integer.MIN_VALUE; min = r[0];
		for (int i = 1; i < r.length; ++i) {
			max = Math.max(max, r[i] - min);
			min = Math.min(min, r[i]);
		}
		out.println(max);
		
		sc.close();
	}

	public static void main(String[] args) {
		(new Main()).run(System.in, System.out);
	}

} public class Main {
	
	public void run(java.io.InputStream in, java.io.PrintStream out) {
		final java.util.Scanner sc = new java.util.Scanner(in);
		final int[] r = new int[sc.nextInt()];
		int max, min;
		
		for (int i = 0; i < r.length; ++i) {
			r[i] = sc.nextInt();
		}
		
		max = Integer.MIN_VALUE; min = r[0];
		for (int i = 1; i < r.length; ++i) {
			max = Math.max(max, r[i] - min);
			min = Math.min(min, r[i]);
		}
		out.println(max);
		
		sc.close();
	}

	public static void main(String[] args) {
		(new Main()).run(System.in, System.out);
	}

} Main
public class Main {
	
	public void run(java.io.InputStream in, java.io.PrintStream out) {
		final java.util.Scanner sc = new java.util.Scanner(in);
		final int[] r = new int[sc.nextInt()];
		int max, min;
		
		for (int i = 0; i < r.length; ++i) {
			r[i] = sc.nextInt();
		}
		
		max = Integer.MIN_VALUE; min = r[0];
		for (int i = 1; i < r.length; ++i) {
			max = Math.max(max, r[i] - min);
			min = Math.min(min, r[i]);
		}
		out.println(max);
		
		sc.close();
	}

	public static void main(String[] args) {
		(new Main()).run(System.in, System.out);
	}

}