import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	int i,j,maxago=Integer.MIN_VALUE,min,max=Integer.MIN_VALUE;
	
	Scanner sca = new Scanner(System.in);
	i=sca.nextInt();
	int[] hai= new int[i];
	hai[0]=sca.nextInt();
	min=hai[0];
	for(i=1;i<hai.length;i++){//i->max(assuming)
	    hai[i]=sca.nextInt();
	    if(hai[i]-min>maxago){
		max=hai[i];
		maxago=max-min;
	    }
	    if(hai[i]<min){
		min=hai[i];
	    }
	    
	}
	System.out.println(maxago);
    }
}
 import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
	int i,j,maxago=Integer.MIN_VALUE,min,max=Integer.MIN_VALUE;
	
	Scanner sca = new Scanner(System.in);
	i=sca.nextInt();
	int[] hai= new int[i];
	hai[0]=sca.nextInt();
	min=hai[0];
	for(i=1;i<hai.length;i++){//i->max(assuming)
	    hai[i]=sca.nextInt();
	    if(hai[i]-min>maxago){
		max=hai[i];
		maxago=max-min;
	    }
	    if(hai[i]<min){
		min=hai[i];
	    }
	    
	}
	System.out.println(maxago);
    }
} Main public static void main(String[] args){
	int i,j,maxago=Integer.MIN_VALUE,min,max=Integer.MIN_VALUE;
	
	Scanner sca = new Scanner(System.in);
	i=sca.nextInt();
	int[] hai= new int[i];
	hai[0]=sca.nextInt();
	min=hai[0];
	for(i=1;i<hai.length;i++){//i->max(assuming)
	    hai[i]=sca.nextInt();
	    if(hai[i]-min>maxago){
		max=hai[i];
		maxago=max-min;
	    }
	    if(hai[i]<min){
		min=hai[i];
	    }
	    
	}
	System.out.println(maxago);
    } main {
	int i,j,maxago=Integer.MIN_VALUE,min,max=Integer.MIN_VALUE;
	
	Scanner sca = new Scanner(System.in);
	i=sca.nextInt();
	int[] hai= new int[i];
	hai[0]=sca.nextInt();
	min=hai[0];
	for(i=1;i<hai.length;i++){//i->max(assuming)
	    hai[i]=sca.nextInt();
	    if(hai[i]-min>maxago){
		max=hai[i];
		maxago=max-min;
	    }
	    if(hai[i]<min){
		min=hai[i];
	    }
	    
	}
	System.out.println(maxago);
    } int i i j j maxago=Integer.MIN_VALUE maxago Integer.MIN_VALUE Integer Integer.MIN_VALUE min min max=Integer.MIN_VALUE; max Integer.MIN_VALUE Integer Integer.MIN_VALUE Scanner sca = new Scanner(System.in); sca new Scanner(System.in) i=sca.nextInt() i sca.nextInt() sca.nextInt sca int[] hai= new int[i]; hai new int[i] i hai[0]=sca.nextInt() hai[0] hai 0 sca.nextInt() sca.nextInt sca min=hai[0] min hai[0] hai 0 for(i=1;i<hai.length;i++){//i->max(assuming)
	    hai[i]=sca.nextInt();
	    if(hai[i]-min>maxago){
		max=hai[i];
		maxago=max-min;
	    }
	    if(hai[i]<min){
		min=hai[i];
	    }
	    
	} i=1; i=1 i 1 i<hai.length i hai.length hai hai.length i++ i++ i {//i->max(assuming)
	    hai[i]=sca.nextInt();
	    if(hai[i]-min>maxago){
		max=hai[i];
		maxago=max-min;
	    }
	    if(hai[i]<min){
		min=hai[i];
	    }
	    
	} {//i->max(assuming)
	    hai[i]=sca.nextInt();
	    if(hai[i]-min>maxago){
		max=hai[i];
		maxago=max-min;
	    }
	    if(hai[i]<min){
		min=hai[i];
	    }
	    
	} hai[i]=sca.nextInt() hai[i] hai i sca.nextInt() sca.nextInt sca if(hai[i]-min>maxago){
		max=hai[i];
		maxago=max-min;
	    } hai[i]-min>maxago hai[i]-min hai[i] hai i min maxago {
		max=hai[i];
		maxago=max-min;
	    } max=hai[i] max hai[i] hai i maxago=max-min maxago max-min max min if(hai[i]<min){
		min=hai[i];
	    } hai[i]<min hai[i] hai i min {
		min=hai[i];
	    } min=hai[i] min hai[i] hai i System.out.println(maxago) System.out.println System.out System System.out maxago String[] args args public class Main{
    public static void main(String[] args){
	int i,j,maxago=Integer.MIN_VALUE,min,max=Integer.MIN_VALUE;
	
	Scanner sca = new Scanner(System.in);
	i=sca.nextInt();
	int[] hai= new int[i];
	hai[0]=sca.nextInt();
	min=hai[0];
	for(i=1;i<hai.length;i++){//i->max(assuming)
	    hai[i]=sca.nextInt();
	    if(hai[i]-min>maxago){
		max=hai[i];
		maxago=max-min;
	    }
	    if(hai[i]<min){
		min=hai[i];
	    }
	    
	}
	System.out.println(maxago);
    }
} public class Main{
    public static void main(String[] args){
	int i,j,maxago=Integer.MIN_VALUE,min,max=Integer.MIN_VALUE;
	
	Scanner sca = new Scanner(System.in);
	i=sca.nextInt();
	int[] hai= new int[i];
	hai[0]=sca.nextInt();
	min=hai[0];
	for(i=1;i<hai.length;i++){//i->max(assuming)
	    hai[i]=sca.nextInt();
	    if(hai[i]-min>maxago){
		max=hai[i];
		maxago=max-min;
	    }
	    if(hai[i]<min){
		min=hai[i];
	    }
	    
	}
	System.out.println(maxago);
    }
} Main
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	int i,j,maxago=Integer.MIN_VALUE,min,max=Integer.MIN_VALUE;
	
	Scanner sca = new Scanner(System.in);
	i=sca.nextInt();
	int[] hai= new int[i];
	hai[0]=sca.nextInt();
	min=hai[0];
	for(i=1;i<hai.length;i++){//i->max(assuming)
	    hai[i]=sca.nextInt();
	    if(hai[i]-min>maxago){
		max=hai[i];
		maxago=max-min;
	    }
	    if(hai[i]<min){
		min=hai[i];
	    }
	    
	}
	System.out.println(maxago);
    }
}

