import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n;
    static int a[];
    static int answer = -1000000000;
    static int minv;


    public static void main(String[] args) {
        read();
        solve();
        System.out.println(answer);
    }

    public static void read() {
        n = sc.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        minv = a[0];

    }

    public static void solve() {
        for (int i = 1; i < n; i++) {
            if (a[i] - minv > answer) {
                answer = a[i] - minv;
            }
            if (minv > a[i]) {
                minv = a[i];
            }
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n;
    static int a[];
    static int answer = -1000000000;
    static int minv;


    public static void main(String[] args) {
        read();
        solve();
        System.out.println(answer);
    }

    public static void read() {
        n = sc.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        minv = a[0];

    }

    public static void solve() {
        for (int i = 1; i < n; i++) {
            if (a[i] - minv > answer) {
                answer = a[i] - minv;
            }
            if (minv > a[i]) {
                minv = a[i];
            }
        }
    }
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) static int n; n static int a[]; a static int answer = -1000000000; answer -1000000000 1000000000 static int minv; minv public static void main(String[] args) {
        read();
        solve();
        System.out.println(answer);
    } main {
        read();
        solve();
        System.out.println(answer);
    } read() read solve() solve System.out.println(answer) System.out.println System.out System System.out answer String[] args args public static void read() {
        n = sc.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        minv = a[0];

    } read {
        n = sc.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        minv = a[0];

    } n = sc.nextInt() n sc.nextInt() sc.nextInt sc a = new int[n] a new int[n] n for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            a[i] = sc.nextInt();
        } {
            a[i] = sc.nextInt();
        } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc minv = a[0] minv a[0] a 0 public static void solve() {
        for (int i = 1; i < n; i++) {
            if (a[i] - minv > answer) {
                answer = a[i] - minv;
            }
            if (minv > a[i]) {
                minv = a[i];
            }
        }
    } solve {
        for (int i = 1; i < n; i++) {
            if (a[i] - minv > answer) {
                answer = a[i] - minv;
            }
            if (minv > a[i]) {
                minv = a[i];
            }
        }
    } for (int i = 1; i < n; i++) {
            if (a[i] - minv > answer) {
                answer = a[i] - minv;
            }
            if (minv > a[i]) {
                minv = a[i];
            }
        } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
            if (a[i] - minv > answer) {
                answer = a[i] - minv;
            }
            if (minv > a[i]) {
                minv = a[i];
            }
        } {
            if (a[i] - minv > answer) {
                answer = a[i] - minv;
            }
            if (minv > a[i]) {
                minv = a[i];
            }
        } if (a[i] - minv > answer) {
                answer = a[i] - minv;
            } a[i] - minv > answer a[i] - minv a[i] a i minv answer {
                answer = a[i] - minv;
            } answer = a[i] - minv answer a[i] - minv a[i] a i minv if (minv > a[i]) {
                minv = a[i];
            } minv > a[i] minv a[i] a i {
                minv = a[i];
            } minv = a[i] minv a[i] a i public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n;
    static int a[];
    static int answer = -1000000000;
    static int minv;


    public static void main(String[] args) {
        read();
        solve();
        System.out.println(answer);
    }

    public static void read() {
        n = sc.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        minv = a[0];

    }

    public static void solve() {
        for (int i = 1; i < n; i++) {
            if (a[i] - minv > answer) {
                answer = a[i] - minv;
            }
            if (minv > a[i]) {
                minv = a[i];
            }
        }
    }
} public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n;
    static int a[];
    static int answer = -1000000000;
    static int minv;


    public static void main(String[] args) {
        read();
        solve();
        System.out.println(answer);
    }

    public static void read() {
        n = sc.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        minv = a[0];

    }

    public static void solve() {
        for (int i = 1; i < n; i++) {
            if (a[i] - minv > answer) {
                answer = a[i] - minv;
            }
            if (minv > a[i]) {
                minv = a[i];
            }
        }
    }
} Main
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n;
    static int a[];
    static int answer = -1000000000;
    static int minv;


    public static void main(String[] args) {
        read();
        solve();
        System.out.println(answer);
    }

    public static void read() {
        n = sc.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        minv = a[0];

    }

    public static void solve() {
        for (int i = 1; i < n; i++) {
            if (a[i] - minv > answer) {
                answer = a[i] - minv;
            }
            if (minv > a[i]) {
                minv = a[i];
            }
        }
    }
}