import java.util.Scanner;

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

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int i, n = scanner.nextInt();
        int min = scanner.nextInt();
        int max = Integer.MIN_VALUE;
        for(i = 1; i < n; ++i){
            int input = scanner.nextInt();
            max = Math.max(max, input - min);
            min = Math.min(min, input);
        }
        System.out.println(max);
        scanner.close();
    }
}
