import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

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

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int min = sc.nextInt();
        int ans = Integer.MIN_VALUE;
        
        for (int i = 0; i < n - 1; i++) {
            int input = sc.nextInt();
            ans = Math.max(input - min, ans);
            min = Math.min(input, min);
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int min = sc.nextInt();
        int ans = Integer.MIN_VALUE;
        
        for (int i = 0; i < n - 1; i++) {
            int input = sc.nextInt();
            ans = Math.max(input - min, ans);
            min = Math.min(input, min);
        }
        System.out.println(ans);
    } main {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

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

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

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

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int min = sc.nextInt();
        int ans = Integer.MIN_VALUE;
        
        for (int i = 0; i < n - 1; i++) {
            int input = sc.nextInt();
            ans = Math.max(input - min, ans);
            min = Math.min(input, min);
        }
        System.out.println(ans);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int min = sc.nextInt();
        int ans = Integer.MIN_VALUE;
        
        for (int i = 0; i < n - 1; i++) {
            int input = sc.nextInt();
            ans = Math.max(input - min, ans);
            min = Math.min(input, min);
        }
        System.out.println(ans);
    }
}
