import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Integer min;
        Integer max = -2000000000;

        List<Integer> IntList = new ArrayList<Integer>();
        Scanner sc;
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0;i<n;i++) {
            IntList.add(Integer.parseInt(sc.next()));
        }

        min = IntList.get(0);
        for (int in = 1;in<IntList.size();in++) {
            max = Math.max(max,IntList.get(in) - min);
            min = Math.min(min,IntList.get(in));
        }

        System.out.println(max);

    }
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        Integer min;
        Integer max = -2000000000;

        List<Integer> IntList = new ArrayList<Integer>();
        Scanner sc;
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0;i<n;i++) {
            IntList.add(Integer.parseInt(sc.next()));
        }

        min = IntList.get(0);
        for (int in = 1;in<IntList.size();in++) {
            max = Math.max(max,IntList.get(in) - min);
            min = Math.min(min,IntList.get(in));
        }

        System.out.println(max);

    }
} Main public static void main(String[] args) {
        Integer min;
        Integer max = -2000000000;

        List<Integer> IntList = new ArrayList<Integer>();
        Scanner sc;
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0;i<n;i++) {
            IntList.add(Integer.parseInt(sc.next()));
        }

        min = IntList.get(0);
        for (int in = 1;in<IntList.size();in++) {
            max = Math.max(max,IntList.get(in) - min);
            min = Math.min(min,IntList.get(in));
        }

        System.out.println(max);

    } main {
        Integer min;
        Integer max = -2000000000;

        List<Integer> IntList = new ArrayList<Integer>();
        Scanner sc;
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0;i<n;i++) {
            IntList.add(Integer.parseInt(sc.next()));
        }

        min = IntList.get(0);
        for (int in = 1;in<IntList.size();in++) {
            max = Math.max(max,IntList.get(in) - min);
            min = Math.min(min,IntList.get(in));
        }

        System.out.println(max);

    } Integer min; min Integer max = -2000000000; max -2000000000 2000000000 List<Integer> IntList = new ArrayList<Integer>(); IntList new ArrayList<Integer>() Scanner sc; sc sc = new Scanner(System.in) sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc for (int i = 0;i<n;i++) {
            IntList.add(Integer.parseInt(sc.next()));
        } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
            IntList.add(Integer.parseInt(sc.next()));
        } {
            IntList.add(Integer.parseInt(sc.next()));
        } IntList.add(Integer.parseInt(sc.next())) IntList.add IntList Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc min = IntList.get(0) min IntList.get(0) IntList.get IntList 0 for (int in = 1;in<IntList.size();in++) {
            max = Math.max(max,IntList.get(in) - min);
            min = Math.min(min,IntList.get(in));
        } int in = 1; int in = 1; in 1 in<IntList.size() in IntList.size() IntList.size IntList in++ in++ in {
            max = Math.max(max,IntList.get(in) - min);
            min = Math.min(min,IntList.get(in));
        } {
            max = Math.max(max,IntList.get(in) - min);
            min = Math.min(min,IntList.get(in));
        } max = Math.max(max,IntList.get(in) - min) max Math.max(max,IntList.get(in) - min) Math.max Math max IntList.get(in) - min IntList.get(in) IntList.get IntList in min min = Math.min(min,IntList.get(in)) min Math.min(min,IntList.get(in)) Math.min Math min IntList.get(in) IntList.get IntList in System.out.println(max) System.out.println System.out System System.out max String[] args args
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Integer min;
        Integer max = -2000000000;

        List<Integer> IntList = new ArrayList<Integer>();
        Scanner sc;
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0;i<n;i++) {
            IntList.add(Integer.parseInt(sc.next()));
        }

        min = IntList.get(0);
        for (int in = 1;in<IntList.size();in++) {
            max = Math.max(max,IntList.get(in) - min);
            min = Math.min(min,IntList.get(in));
        }

        System.out.println(max);

    }
}
