
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = Integer.parseInt(sc.nextLine());
        int n0 = Integer.parseInt(sc.nextLine());
        int n1 = Integer.parseInt(sc.nextLine());

        int max = n1 - n0;
        int min = Math.min(n0, n1);

        for(int i = 2; i < n; i++){
            int a = Integer.parseInt(sc.nextLine());
            max = Math.max(max, a - min);
            min = Math.min(min, a);
        }
        System.out.println(max);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = Integer.parseInt(sc.nextLine());
        int n0 = Integer.parseInt(sc.nextLine());
        int n1 = Integer.parseInt(sc.nextLine());

        int max = n1 - n0;
        int min = Math.min(n0, n1);

        for(int i = 2; i < n; i++){
            int a = Integer.parseInt(sc.nextLine());
            max = Math.max(max, a - min);
            min = Math.min(min, a);
        }
        System.out.println(max);
    }
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
        int n = Integer.parseInt(sc.nextLine());
        int n0 = Integer.parseInt(sc.nextLine());
        int n1 = Integer.parseInt(sc.nextLine());

        int max = n1 - n0;
        int min = Math.min(n0, n1);

        for(int i = 2; i < n; i++){
            int a = Integer.parseInt(sc.nextLine());
            max = Math.max(max, a - min);
            min = Math.min(min, a);
        }
        System.out.println(max);
    } main {
        int n = Integer.parseInt(sc.nextLine());
        int n0 = Integer.parseInt(sc.nextLine());
        int n1 = Integer.parseInt(sc.nextLine());

        int max = n1 - n0;
        int min = Math.min(n0, n1);

        for(int i = 2; i < n; i++){
            int a = Integer.parseInt(sc.nextLine());
            max = Math.max(max, a - min);
            min = Math.min(min, a);
        }
        System.out.println(max);
    } int n = Integer.parseInt(sc.nextLine()); n Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc int n0 = Integer.parseInt(sc.nextLine()); n0 Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc int n1 = Integer.parseInt(sc.nextLine()); n1 Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc int max = n1 - n0; max n1 - n0 n1 n0 int min = Math.min(n0, n1); min Math.min(n0, n1) Math.min Math n0 n1 for(int i = 2; i < n; i++){
            int a = Integer.parseInt(sc.nextLine());
            max = Math.max(max, a - min);
            min = Math.min(min, a);
        } int i = 2; int i = 2; i 2 i < n i n i++ i++ i {
            int a = Integer.parseInt(sc.nextLine());
            max = Math.max(max, a - min);
            min = Math.min(min, a);
        } {
            int a = Integer.parseInt(sc.nextLine());
            max = Math.max(max, a - min);
            min = Math.min(min, a);
        } int a = Integer.parseInt(sc.nextLine()); a Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc max = Math.max(max, a - min) max Math.max(max, a - min) Math.max Math max a - min a min min = Math.min(min, a) min Math.min(min, a) Math.min Math min a System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = Integer.parseInt(sc.nextLine());
        int n0 = Integer.parseInt(sc.nextLine());
        int n1 = Integer.parseInt(sc.nextLine());

        int max = n1 - n0;
        int min = Math.min(n0, n1);

        for(int i = 2; i < n; i++){
            int a = Integer.parseInt(sc.nextLine());
            max = Math.max(max, a - min);
            min = Math.min(min, a);
        }
        System.out.println(max);
    }
} public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = Integer.parseInt(sc.nextLine());
        int n0 = Integer.parseInt(sc.nextLine());
        int n1 = Integer.parseInt(sc.nextLine());

        int max = n1 - n0;
        int min = Math.min(n0, n1);

        for(int i = 2; i < n; i++){
            int a = Integer.parseInt(sc.nextLine());
            max = Math.max(max, a - min);
            min = Math.min(min, a);
        }
        System.out.println(max);
    }
} Main

import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = Integer.parseInt(sc.nextLine());
        int n0 = Integer.parseInt(sc.nextLine());
        int n1 = Integer.parseInt(sc.nextLine());

        int max = n1 - n0;
        int min = Math.min(n0, n1);

        for(int i = 2; i < n; i++){
            int a = Integer.parseInt(sc.nextLine());
            max = Math.max(max, a - min);
            min = Math.min(min, a);
        }
        System.out.println(max);
    }
}
