import java.util.Scanner;

public class Main {

    static final int max = 200000;
    public static void main(String[]args){
        int R[] = new int[max];
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i<n; i++)
        {
            R[i]= scanner.nextInt();
        }

        int maxv = -2000000000; //设置一个足够小的值
        int minv = R[0];

        for (int i = 1; i<n; i++){
            maxv = Math.max(maxv,R[i]-minv);
            minv = Math.min(minv,R[i]);
        }
        System.out.println(maxv);
    }
}
 import java.util.Scanner; Scanner java.util public class Main {

    static final int max = 200000;
    public static void main(String[]args){
        int R[] = new int[max];
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i<n; i++)
        {
            R[i]= scanner.nextInt();
        }

        int maxv = -2000000000; //设置一个足够小的值
        int minv = R[0];

        for (int i = 1; i<n; i++){
            maxv = Math.max(maxv,R[i]-minv);
            minv = Math.min(minv,R[i]);
        }
        System.out.println(maxv);
    }
} Main static final int max = 200000; max 200000 public static void main(String[]args){
        int R[] = new int[max];
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i<n; i++)
        {
            R[i]= scanner.nextInt();
        }

        int maxv = -2000000000; //设置一个足够小的值
        int minv = R[0];

        for (int i = 1; i<n; i++){
            maxv = Math.max(maxv,R[i]-minv);
            minv = Math.min(minv,R[i]);
        }
        System.out.println(maxv);
    } main {
        int R[] = new int[max];
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i<n; i++)
        {
            R[i]= scanner.nextInt();
        }

        int maxv = -2000000000; //设置一个足够小的值
        int minv = R[0];

        for (int i = 1; i<n; i++){
            maxv = Math.max(maxv,R[i]-minv);
            minv = Math.min(minv,R[i]);
        }
        System.out.println(maxv);
    } int R[] = new int[max]; R new int[max] max Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner for (int i = 0; i<n; i++)
        {
            R[i]= scanner.nextInt();
        } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
            R[i]= scanner.nextInt();
        } {
            R[i]= scanner.nextInt();
        } R[i]= scanner.nextInt() R[i] R i scanner.nextInt() scanner.nextInt scanner int maxv = -2000000000; maxv -2000000000 2000000000 int minv = R[0]; minv R[0] R 0 for (int i = 1; i<n; i++){
            maxv = Math.max(maxv,R[i]-minv);
            minv = Math.min(minv,R[i]);
        } int i = 1; int i = 1; i 1 i<n i n i++ i++ i {
            maxv = Math.max(maxv,R[i]-minv);
            minv = Math.min(minv,R[i]);
        } {
            maxv = Math.max(maxv,R[i]-minv);
            minv = Math.min(minv,R[i]);
        } maxv = Math.max(maxv,R[i]-minv) maxv Math.max(maxv,R[i]-minv) Math.max Math maxv R[i]-minv R[i] R i minv minv = Math.min(minv,R[i]) minv Math.min(minv,R[i]) Math.min Math minv R[i] R i System.out.println(maxv) System.out.println System.out System System.out maxv String[]args args public class Main {

    static final int max = 200000;
    public static void main(String[]args){
        int R[] = new int[max];
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i<n; i++)
        {
            R[i]= scanner.nextInt();
        }

        int maxv = -2000000000; //设置一个足够小的值
        int minv = R[0];

        for (int i = 1; i<n; i++){
            maxv = Math.max(maxv,R[i]-minv);
            minv = Math.min(minv,R[i]);
        }
        System.out.println(maxv);
    }
} public class Main {

    static final int max = 200000;
    public static void main(String[]args){
        int R[] = new int[max];
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i<n; i++)
        {
            R[i]= scanner.nextInt();
        }

        int maxv = -2000000000; //设置一个足够小的值
        int minv = R[0];

        for (int i = 1; i<n; i++){
            maxv = Math.max(maxv,R[i]-minv);
            minv = Math.min(minv,R[i]);
        }
        System.out.println(maxv);
    }
} Main
import java.util.Scanner;

public class Main {

    static final int max = 200000;
    public static void main(String[]args){
        int R[] = new int[max];
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i<n; i++)
        {
            R[i]= scanner.nextInt();
        }

        int maxv = -2000000000; //设置一个足够小的值
        int minv = R[0];

        for (int i = 1; i<n; i++){
            maxv = Math.max(maxv,R[i]-minv);
            minv = Math.min(minv,R[i]);
        }
        System.out.println(maxv);
    }
}

