import java.util.Scanner;

public class Main {

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

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

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

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int max = Integer.MIN_VALUE, min = sc.nextInt();
        for (int i = 1; i < count; i++) {
            int v = sc.nextInt();
            max = Math.max(max, v - min);
            min = Math.min(min, v);
        }
        System.out.println(max);
    }
}