import java.util.Scanner;

/**
 * Created by shoya on 2017/04/14.
 */
public class Main {
    public static void main(String... args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        final long INF = 1L << 60;
        long currentmin = INF;
        long maxpro = -INF;
        for (int i = 0; i < n; i++){
            long a = sc.nextInt();
            if (maxpro < a - currentmin)
                maxpro = a - currentmin;
            if (currentmin > a)
                currentmin = a;
        }
        System.out.println(maxpro);
        return;
    }
} 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();
        final long INF = 1L << 60;
        long currentmin = INF;
        long maxpro = -INF;
        for (int i = 0; i < n; i++){
            long a = sc.nextInt();
            if (maxpro < a - currentmin)
                maxpro = a - currentmin;
            if (currentmin > a)
                currentmin = a;
        }
        System.out.println(maxpro);
        return;
    }
} Main public static void main(String... args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        final long INF = 1L << 60;
        long currentmin = INF;
        long maxpro = -INF;
        for (int i = 0; i < n; i++){
            long a = sc.nextInt();
            if (maxpro < a - currentmin)
                maxpro = a - currentmin;
            if (currentmin > a)
                currentmin = a;
        }
        System.out.println(maxpro);
        return;
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        final long INF = 1L << 60;
        long currentmin = INF;
        long maxpro = -INF;
        for (int i = 0; i < n; i++){
            long a = sc.nextInt();
            if (maxpro < a - currentmin)
                maxpro = a - currentmin;
            if (currentmin > a)
                currentmin = a;
        }
        System.out.println(maxpro);
        return;
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc final long INF = 1L << 60; INF 1L << 60 1L 60 long currentmin = INF; currentmin INF long maxpro = -INF; maxpro -INF INF for (int i = 0; i < n; i++){
            long a = sc.nextInt();
            if (maxpro < a - currentmin)
                maxpro = a - currentmin;
            if (currentmin > a)
                currentmin = a;
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            long a = sc.nextInt();
            if (maxpro < a - currentmin)
                maxpro = a - currentmin;
            if (currentmin > a)
                currentmin = a;
        } {
            long a = sc.nextInt();
            if (maxpro < a - currentmin)
                maxpro = a - currentmin;
            if (currentmin > a)
                currentmin = a;
        } long a = sc.nextInt(); a sc.nextInt() sc.nextInt sc if (maxpro < a - currentmin)
                maxpro = a - currentmin; maxpro < a - currentmin maxpro a - currentmin a currentmin maxpro = a - currentmin maxpro a - currentmin a currentmin if (currentmin > a)
                currentmin = a; currentmin > a currentmin a currentmin = a currentmin a System.out.println(maxpro) System.out.println System.out System System.out maxpro return; String... args args public class Main {
    public static void main(String... args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        final long INF = 1L << 60;
        long currentmin = INF;
        long maxpro = -INF;
        for (int i = 0; i < n; i++){
            long a = sc.nextInt();
            if (maxpro < a - currentmin)
                maxpro = a - currentmin;
            if (currentmin > a)
                currentmin = a;
        }
        System.out.println(maxpro);
        return;
    }
} public class Main {
    public static void main(String... args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        final long INF = 1L << 60;
        long currentmin = INF;
        long maxpro = -INF;
        for (int i = 0; i < n; i++){
            long a = sc.nextInt();
            if (maxpro < a - currentmin)
                maxpro = a - currentmin;
            if (currentmin > a)
                currentmin = a;
        }
        System.out.println(maxpro);
        return;
    }
} Main
import java.util.Scanner;

/**
 * Created by shoya on 2017/04/14.
 */
public class Main {
    public static void main(String... args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        final long INF = 1L << 60;
        long currentmin = INF;
        long maxpro = -INF;
        for (int i = 0; i < n; i++){
            long a = sc.nextInt();
            if (maxpro < a - currentmin)
                maxpro = a - currentmin;
            if (currentmin > a)
                currentmin = a;
        }
        System.out.println(maxpro);
        return;
    }
}