import java.io.*;
import java.util.*;



class Main{
    //読み込みのテンプレ(stringオブジェクトまで)
    
    static int minimum;
    static int gap;
    
    public static void main(String[] args) throws IOException{
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        int minimum = scanner.nextInt();
        int time = scanner.nextInt();
        
        //minimumはその時点での最小値のことである
        
        gap = time - minimum;
        if(minimum >= time)minimum = time;
        
        for(int i = 0;i<number - 2;i++){
            time = scanner.nextInt();
            
            if(time - minimum >= gap)gap = time - minimum;
            if(minimum >= time)minimum = time;
        }
        
        System.out.println(gap);
    
    
    }
} import java.io.*; io.* java import java.util.*; util.* java class Main{
    //読み込みのテンプレ(stringオブジェクトまで)
    
    static int minimum;
    static int gap;
    
    public static void main(String[] args) throws IOException{
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        int minimum = scanner.nextInt();
        int time = scanner.nextInt();
        
        //minimumはその時点での最小値のことである
        
        gap = time - minimum;
        if(minimum >= time)minimum = time;
        
        for(int i = 0;i<number - 2;i++){
            time = scanner.nextInt();
            
            if(time - minimum >= gap)gap = time - minimum;
            if(minimum >= time)minimum = time;
        }
        
        System.out.println(gap);
    
    
    }
} Main static int minimum; minimum static int gap; gap public static void main(String[] args) throws IOException{
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        int minimum = scanner.nextInt();
        int time = scanner.nextInt();
        
        //minimumはその時点での最小値のことである
        
        gap = time - minimum;
        if(minimum >= time)minimum = time;
        
        for(int i = 0;i<number - 2;i++){
            time = scanner.nextInt();
            
            if(time - minimum >= gap)gap = time - minimum;
            if(minimum >= time)minimum = time;
        }
        
        System.out.println(gap);
    
    
    } main {
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        int minimum = scanner.nextInt();
        int time = scanner.nextInt();
        
        //minimumはその時点での最小値のことである
        
        gap = time - minimum;
        if(minimum >= time)minimum = time;
        
        for(int i = 0;i<number - 2;i++){
            time = scanner.nextInt();
            
            if(time - minimum >= gap)gap = time - minimum;
            if(minimum >= time)minimum = time;
        }
        
        System.out.println(gap);
    
    
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int number = scanner.nextInt(); number scanner.nextInt() scanner.nextInt scanner int minimum = scanner.nextInt(); minimum scanner.nextInt() scanner.nextInt scanner int time = scanner.nextInt(); time scanner.nextInt() scanner.nextInt scanner gap = time - minimum gap time - minimum time minimum if(minimum >= time)minimum = time; minimum >= time minimum time minimum = time minimum time for(int i = 0;i<number - 2;i++){
            time = scanner.nextInt();
            
            if(time - minimum >= gap)gap = time - minimum;
            if(minimum >= time)minimum = time;
        } int i = 0; int i = 0; i 0 i<number - 2 i number - 2 number 2 i++ i++ i {
            time = scanner.nextInt();
            
            if(time - minimum >= gap)gap = time - minimum;
            if(minimum >= time)minimum = time;
        } {
            time = scanner.nextInt();
            
            if(time - minimum >= gap)gap = time - minimum;
            if(minimum >= time)minimum = time;
        } time = scanner.nextInt() time scanner.nextInt() scanner.nextInt scanner if(time - minimum >= gap)gap = time - minimum; time - minimum >= gap time - minimum time minimum gap gap = time - minimum gap time - minimum time minimum if(minimum >= time)minimum = time; minimum >= time minimum time minimum = time minimum time System.out.println(gap) System.out.println System.out System System.out gap String[] args args
import java.io.*;
import java.util.*;



class Main{
    //読み込みのテンプレ(stringオブジェクトまで)
    
    static int minimum;
    static int gap;
    
    public static void main(String[] args) throws IOException{
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        int minimum = scanner.nextInt();
        int time = scanner.nextInt();
        
        //minimumはその時点での最小値のことである
        
        gap = time - minimum;
        if(minimum >= time)minimum = time;
        
        for(int i = 0;i<number - 2;i++){
            time = scanner.nextInt();
            
            if(time - minimum >= gap)gap = time - minimum;
            if(minimum >= time)minimum = time;
        }
        
        System.out.println(gap);
    
    
    }
}