
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int min=Integer.MAX_VALUE;
        int result=Integer.MIN_VALUE;
        int x=0;
        for(int i=0;i<n;i++){
            x=scanner.nextInt();
            result=x-min>result?x-min:result;
            min=min>x?x:min;
        }
        System.out.println(result);
    }

}
 import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int min=Integer.MAX_VALUE;
        int result=Integer.MIN_VALUE;
        int x=0;
        for(int i=0;i<n;i++){
            x=scanner.nextInt();
            result=x-min>result?x-min:result;
            min=min>x?x:min;
        }
        System.out.println(result);
    }

} Main public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int min=Integer.MAX_VALUE;
        int result=Integer.MIN_VALUE;
        int x=0;
        for(int i=0;i<n;i++){
            x=scanner.nextInt();
            result=x-min>result?x-min:result;
            min=min>x?x:min;
        }
        System.out.println(result);
    } main {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int min=Integer.MAX_VALUE;
        int result=Integer.MIN_VALUE;
        int x=0;
        for(int i=0;i<n;i++){
            x=scanner.nextInt();
            result=x-min>result?x-min:result;
            min=min>x?x:min;
        }
        System.out.println(result);
    } Scanner scanner=new Scanner(System.in); scanner new Scanner(System.in) int n=scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int min=Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE int result=Integer.MIN_VALUE; result Integer.MIN_VALUE Integer Integer.MIN_VALUE int x=0; x 0 for(int i=0;i<n;i++){
            x=scanner.nextInt();
            result=x-min>result?x-min:result;
            min=min>x?x:min;
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            x=scanner.nextInt();
            result=x-min>result?x-min:result;
            min=min>x?x:min;
        } {
            x=scanner.nextInt();
            result=x-min>result?x-min:result;
            min=min>x?x:min;
        } x=scanner.nextInt() x scanner.nextInt() scanner.nextInt scanner result=x-min>result?x-min:result result x-min>result?x-min:result x-min>result x-min x min result x-min x min result min=min>x?x:min min min>x?x:min min>x min x x min System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int min=Integer.MAX_VALUE;
        int result=Integer.MIN_VALUE;
        int x=0;
        for(int i=0;i<n;i++){
            x=scanner.nextInt();
            result=x-min>result?x-min:result;
            min=min>x?x:min;
        }
        System.out.println(result);
    }

} public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int min=Integer.MAX_VALUE;
        int result=Integer.MIN_VALUE;
        int x=0;
        for(int i=0;i<n;i++){
            x=scanner.nextInt();
            result=x-min>result?x-min:result;
            min=min>x?x:min;
        }
        System.out.println(result);
    }

} Main

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int min=Integer.MAX_VALUE;
        int result=Integer.MIN_VALUE;
        int x=0;
        for(int i=0;i<n;i++){
            x=scanner.nextInt();
            result=x-min>result?x-min:result;
            min=min>x?x:min;
        }
        System.out.println(result);
    }

}

