import java.util.Scanner;

class Main
{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int[] r = new int[200000];
		int kai = -1000000000;
		
		int n = scan.nextInt();
		
		for(int i=0; i<n; i++){
			r[i] = scan.nextInt();
		}
		int min = r[0];
		int max = -1000000000;
		
		for(int j=1; j<n; j++){
			if(max < r[j]-min){
				max = r[j] - min;
			}
			if(min > r[j]){
				min = r[j];
			}
		}
		
		System.out.println(max);
	}
} import java.util.Scanner; Scanner java.util class Main
{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int[] r = new int[200000];
		int kai = -1000000000;
		
		int n = scan.nextInt();
		
		for(int i=0; i<n; i++){
			r[i] = scan.nextInt();
		}
		int min = r[0];
		int max = -1000000000;
		
		for(int j=1; j<n; j++){
			if(max < r[j]-min){
				max = r[j] - min;
			}
			if(min > r[j]){
				min = r[j];
			}
		}
		
		System.out.println(max);
	}
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int[] r = new int[200000];
		int kai = -1000000000;
		
		int n = scan.nextInt();
		
		for(int i=0; i<n; i++){
			r[i] = scan.nextInt();
		}
		int min = r[0];
		int max = -1000000000;
		
		for(int j=1; j<n; j++){
			if(max < r[j]-min){
				max = r[j] - min;
			}
			if(min > r[j]){
				min = r[j];
			}
		}
		
		System.out.println(max);
	} main {
		Scanner scan = new Scanner(System.in);
		
		int[] r = new int[200000];
		int kai = -1000000000;
		
		int n = scan.nextInt();
		
		for(int i=0; i<n; i++){
			r[i] = scan.nextInt();
		}
		int min = r[0];
		int max = -1000000000;
		
		for(int j=1; j<n; j++){
			if(max < r[j]-min){
				max = r[j] - min;
			}
			if(min > r[j]){
				min = r[j];
			}
		}
		
		System.out.println(max);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int[] r = new int[200000]; r new int[200000] 200000 int kai = -1000000000; kai -1000000000 1000000000 int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan for(int i=0; i<n; i++){
			r[i] = scan.nextInt();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			r[i] = scan.nextInt();
		} {
			r[i] = scan.nextInt();
		} r[i] = scan.nextInt() r[i] r i scan.nextInt() scan.nextInt scan int min = r[0]; min r[0] r 0 int max = -1000000000; max -1000000000 1000000000 for(int j=1; j<n; j++){
			if(max < r[j]-min){
				max = r[j] - min;
			}
			if(min > r[j]){
				min = r[j];
			}
		} int j=1; int j=1; j 1 j<n j n j++ j++ j {
			if(max < r[j]-min){
				max = r[j] - min;
			}
			if(min > r[j]){
				min = r[j];
			}
		} {
			if(max < r[j]-min){
				max = r[j] - min;
			}
			if(min > r[j]){
				min = r[j];
			}
		} if(max < r[j]-min){
				max = r[j] - min;
			} max < r[j]-min max r[j]-min r[j] r j min {
				max = r[j] - min;
			} max = r[j] - min max r[j] - min r[j] r j min if(min > r[j]){
				min = r[j];
			} min > r[j] min r[j] r j {
				min = r[j];
			} min = r[j] min r[j] r j System.out.println(max) System.out.println System.out System System.out max String[] args args
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int[] r = new int[200000];
		int kai = -1000000000;
		
		int n = scan.nextInt();
		
		for(int i=0; i<n; i++){
			r[i] = scan.nextInt();
		}
		int min = r[0];
		int max = -1000000000;
		
		for(int j=1; j<n; j++){
			if(max < r[j]-min){
				max = r[j] - min;
			}
			if(min > r[j]){
				min = r[j];
			}
		}
		
		System.out.println(max);
	}
}
