import java.util.Scanner;

class Main{

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.nextLine());
        int dif = -2000000000;
        int min = Integer.parseInt(scan.nextLine());
        int number;
        for(int i=1; i<n; i++){
            number = Integer.parseInt(scan.nextLine());
            dif = Math.max(dif, number-min);
            min = Math.min(min, number);
        }
        
        System.out.println(dif);
    }
    
} import java.util.Scanner; Scanner java.util class Main{

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.nextLine());
        int dif = -2000000000;
        int min = Integer.parseInt(scan.nextLine());
        int number;
        for(int i=1; i<n; i++){
            number = Integer.parseInt(scan.nextLine());
            dif = Math.max(dif, number-min);
            min = Math.min(min, number);
        }
        
        System.out.println(dif);
    }
    
} Main public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.nextLine());
        int dif = -2000000000;
        int min = Integer.parseInt(scan.nextLine());
        int number;
        for(int i=1; i<n; i++){
            number = Integer.parseInt(scan.nextLine());
            dif = Math.max(dif, number-min);
            min = Math.min(min, number);
        }
        
        System.out.println(dif);
    } main {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.nextLine());
        int dif = -2000000000;
        int min = Integer.parseInt(scan.nextLine());
        int number;
        for(int i=1; i<n; i++){
            number = Integer.parseInt(scan.nextLine());
            dif = Math.max(dif, number-min);
            min = Math.min(min, number);
        }
        
        System.out.println(dif);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = Integer.parseInt(scan.nextLine()); n Integer.parseInt(scan.nextLine()) Integer.parseInt Integer scan.nextLine() scan.nextLine scan int dif = -2000000000; dif -2000000000 2000000000 int min = Integer.parseInt(scan.nextLine()); min Integer.parseInt(scan.nextLine()) Integer.parseInt Integer scan.nextLine() scan.nextLine scan int number; number for(int i=1; i<n; i++){
            number = Integer.parseInt(scan.nextLine());
            dif = Math.max(dif, number-min);
            min = Math.min(min, number);
        } int i=1; int i=1; i 1 i<n i n i++ i++ i {
            number = Integer.parseInt(scan.nextLine());
            dif = Math.max(dif, number-min);
            min = Math.min(min, number);
        } {
            number = Integer.parseInt(scan.nextLine());
            dif = Math.max(dif, number-min);
            min = Math.min(min, number);
        } number = Integer.parseInt(scan.nextLine()) number Integer.parseInt(scan.nextLine()) Integer.parseInt Integer scan.nextLine() scan.nextLine scan dif = Math.max(dif, number-min) dif Math.max(dif, number-min) Math.max Math dif number-min number min min = Math.min(min, number) min Math.min(min, number) Math.min Math min number System.out.println(dif) System.out.println System.out System System.out dif String[] args args
import java.util.Scanner;

class Main{

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.nextLine());
        int dif = -2000000000;
        int min = Integer.parseInt(scan.nextLine());
        int number;
        for(int i=1; i<n; i++){
            number = Integer.parseInt(scan.nextLine());
            dif = Math.max(dif, number-min);
            min = Math.min(min, number);
        }
        
        System.out.println(dif);
    }
    
}