import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.next());
        Integer minValue = Integer.parseInt(scanner.next());
        Integer maxDiff = -1000000001;
        for (int i = 1; i < n; i++) {
            int value = Integer.parseInt(scanner.next());
            maxDiff = Math.max(maxDiff, value - minValue);
            minValue = Math.min(minValue, value);
        }
        System.out.println(maxDiff);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.next());
        Integer minValue = Integer.parseInt(scanner.next());
        Integer maxDiff = -1000000001;
        for (int i = 1; i < n; i++) {
            int value = Integer.parseInt(scanner.next());
            maxDiff = Math.max(maxDiff, value - minValue);
            minValue = Math.min(minValue, value);
        }
        System.out.println(maxDiff);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.next());
        Integer minValue = Integer.parseInt(scanner.next());
        Integer maxDiff = -1000000001;
        for (int i = 1; i < n; i++) {
            int value = Integer.parseInt(scanner.next());
            maxDiff = Math.max(maxDiff, value - minValue);
            minValue = Math.min(minValue, value);
        }
        System.out.println(maxDiff);
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.next());
        Integer minValue = Integer.parseInt(scanner.next());
        Integer maxDiff = -1000000001;
        for (int i = 1; i < n; i++) {
            int value = Integer.parseInt(scanner.next());
            maxDiff = Math.max(maxDiff, value - minValue);
            minValue = Math.min(minValue, value);
        }
        System.out.println(maxDiff);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = Integer.parseInt(scanner.next()); n Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner Integer minValue = Integer.parseInt(scanner.next()); minValue Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner Integer maxDiff = -1000000001; maxDiff -1000000001 1000000001 for (int i = 1; i < n; i++) {
            int value = Integer.parseInt(scanner.next());
            maxDiff = Math.max(maxDiff, value - minValue);
            minValue = Math.min(minValue, value);
        } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
            int value = Integer.parseInt(scanner.next());
            maxDiff = Math.max(maxDiff, value - minValue);
            minValue = Math.min(minValue, value);
        } {
            int value = Integer.parseInt(scanner.next());
            maxDiff = Math.max(maxDiff, value - minValue);
            minValue = Math.min(minValue, value);
        } int value = Integer.parseInt(scanner.next()); value Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner maxDiff = Math.max(maxDiff, value - minValue) maxDiff Math.max(maxDiff, value - minValue) Math.max Math maxDiff value - minValue value minValue minValue = Math.min(minValue, value) minValue Math.min(minValue, value) Math.min Math minValue value System.out.println(maxDiff) System.out.println System.out System System.out maxDiff String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.next());
        Integer minValue = Integer.parseInt(scanner.next());
        Integer maxDiff = -1000000001;
        for (int i = 1; i < n; i++) {
            int value = Integer.parseInt(scanner.next());
            maxDiff = Math.max(maxDiff, value - minValue);
            minValue = Math.min(minValue, value);
        }
        System.out.println(maxDiff);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.next());
        Integer minValue = Integer.parseInt(scanner.next());
        Integer maxDiff = -1000000001;
        for (int i = 1; i < n; i++) {
            int value = Integer.parseInt(scanner.next());
            maxDiff = Math.max(maxDiff, value - minValue);
            minValue = Math.min(minValue, value);
        }
        System.out.println(maxDiff);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.next());
        Integer minValue = Integer.parseInt(scanner.next());
        Integer maxDiff = -1000000001;
        for (int i = 1; i < n; i++) {
            int value = Integer.parseInt(scanner.next());
            maxDiff = Math.max(maxDiff, value - minValue);
            minValue = Math.min(minValue, value);
        }
        System.out.println(maxDiff);
    }
}