import java.util.*;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n=sc.nextInt();
    	int[] ary =new int[n];
    	int i,m;
    	int reg=0;
    	int min=0;
    	int max=0;
    	for(i=0;i<n;i++){
    		m=sc.nextInt();
    		if(i==0){
    			min=m;
    		}
    		if(i==1){
    			max=m-min;
    		}
        
    		if(m-min>max){
    			max=m-min;
    		}
    		if(m<min){
    			min=m;
    		}
    		
    	}
    	System.out.println(max);

    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n=sc.nextInt();
    	int[] ary =new int[n];
    	int i,m;
    	int reg=0;
    	int min=0;
    	int max=0;
    	for(i=0;i<n;i++){
    		m=sc.nextInt();
    		if(i==0){
    			min=m;
    		}
    		if(i==1){
    			max=m-min;
    		}
        
    		if(m-min>max){
    			max=m-min;
    		}
    		if(m<min){
    			min=m;
    		}
    		
    	}
    	System.out.println(max);

    }
} Main public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n=sc.nextInt();
    	int[] ary =new int[n];
    	int i,m;
    	int reg=0;
    	int min=0;
    	int max=0;
    	for(i=0;i<n;i++){
    		m=sc.nextInt();
    		if(i==0){
    			min=m;
    		}
    		if(i==1){
    			max=m-min;
    		}
        
    		if(m-min>max){
    			max=m-min;
    		}
    		if(m<min){
    			min=m;
    		}
    		
    	}
    	System.out.println(max);

    } main {
    	Scanner sc = new Scanner(System.in);
    	int n=sc.nextInt();
    	int[] ary =new int[n];
    	int i,m;
    	int reg=0;
    	int min=0;
    	int max=0;
    	for(i=0;i<n;i++){
    		m=sc.nextInt();
    		if(i==0){
    			min=m;
    		}
    		if(i==1){
    			max=m-min;
    		}
        
    		if(m-min>max){
    			max=m-min;
    		}
    		if(m<min){
    			min=m;
    		}
    		
    	}
    	System.out.println(max);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] ary =new int[n]; ary new int[n] n int i i m; m int reg=0; reg 0 int min=0; min 0 int max=0; max 0 for(i=0;i<n;i++){
    		m=sc.nextInt();
    		if(i==0){
    			min=m;
    		}
    		if(i==1){
    			max=m-min;
    		}
        
    		if(m-min>max){
    			max=m-min;
    		}
    		if(m<min){
    			min=m;
    		}
    		
    	} i=0; i=0 i 0 i<n i n i++ i++ i {
    		m=sc.nextInt();
    		if(i==0){
    			min=m;
    		}
    		if(i==1){
    			max=m-min;
    		}
        
    		if(m-min>max){
    			max=m-min;
    		}
    		if(m<min){
    			min=m;
    		}
    		
    	} {
    		m=sc.nextInt();
    		if(i==0){
    			min=m;
    		}
    		if(i==1){
    			max=m-min;
    		}
        
    		if(m-min>max){
    			max=m-min;
    		}
    		if(m<min){
    			min=m;
    		}
    		
    	} m=sc.nextInt() m sc.nextInt() sc.nextInt sc if(i==0){
    			min=m;
    		} i==0 i 0 {
    			min=m;
    		} min=m min m if(i==1){
    			max=m-min;
    		} i==1 i 1 {
    			max=m-min;
    		} max=m-min max m-min m min if(m-min>max){
    			max=m-min;
    		} m-min>max m-min m min max {
    			max=m-min;
    		} max=m-min max m-min m min if(m<min){
    			min=m;
    		} m<min m min {
    			min=m;
    		} min=m min m System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n=sc.nextInt();
    	int[] ary =new int[n];
    	int i,m;
    	int reg=0;
    	int min=0;
    	int max=0;
    	for(i=0;i<n;i++){
    		m=sc.nextInt();
    		if(i==0){
    			min=m;
    		}
    		if(i==1){
    			max=m-min;
    		}
        
    		if(m-min>max){
    			max=m-min;
    		}
    		if(m<min){
    			min=m;
    		}
    		
    	}
    	System.out.println(max);

    }
} public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n=sc.nextInt();
    	int[] ary =new int[n];
    	int i,m;
    	int reg=0;
    	int min=0;
    	int max=0;
    	for(i=0;i<n;i++){
    		m=sc.nextInt();
    		if(i==0){
    			min=m;
    		}
    		if(i==1){
    			max=m-min;
    		}
        
    		if(m-min>max){
    			max=m-min;
    		}
    		if(m<min){
    			min=m;
    		}
    		
    	}
    	System.out.println(max);

    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n=sc.nextInt();
    	int[] ary =new int[n];
    	int i,m;
    	int reg=0;
    	int min=0;
    	int max=0;
    	for(i=0;i<n;i++){
    		m=sc.nextInt();
    		if(i==0){
    			min=m;
    		}
    		if(i==1){
    			max=m-min;
    		}
        
    		if(m-min>max){
    			max=m-min;
    		}
    		if(m<min){
    			min=m;
    		}
    		
    	}
    	System.out.println(max);

    }
}
