import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int minRate;
        int maxProfit = Integer.MIN_VALUE;
        int r = in.nextInt();
        minRate = r;

        for (int i = 1; i < n; i++) {
            r = in.nextInt();
            maxProfit = (maxProfit > r - minRate)? maxProfit : r - minRate;
            if(r < minRate) minRate = r;
        }
        System.out.println(maxProfit);
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int minRate;
        int maxProfit = Integer.MIN_VALUE;
        int r = in.nextInt();
        minRate = r;

        for (int i = 1; i < n; i++) {
            r = in.nextInt();
            maxProfit = (maxProfit > r - minRate)? maxProfit : r - minRate;
            if(r < minRate) minRate = r;
        }
        System.out.println(maxProfit);
    }
} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int minRate;
        int maxProfit = Integer.MIN_VALUE;
        int r = in.nextInt();
        minRate = r;

        for (int i = 1; i < n; i++) {
            r = in.nextInt();
            maxProfit = (maxProfit > r - minRate)? maxProfit : r - minRate;
            if(r < minRate) minRate = r;
        }
        System.out.println(maxProfit);
    } main {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int minRate;
        int maxProfit = Integer.MIN_VALUE;
        int r = in.nextInt();
        minRate = r;

        for (int i = 1; i < n; i++) {
            r = in.nextInt();
            maxProfit = (maxProfit > r - minRate)? maxProfit : r - minRate;
            if(r < minRate) minRate = r;
        }
        System.out.println(maxProfit);
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int n = in.nextInt(); n in.nextInt() in.nextInt in int minRate; minRate int maxProfit = Integer.MIN_VALUE; maxProfit Integer.MIN_VALUE Integer Integer.MIN_VALUE int r = in.nextInt(); r in.nextInt() in.nextInt in minRate = r minRate r for (int i = 1; i < n; i++) {
            r = in.nextInt();
            maxProfit = (maxProfit > r - minRate)? maxProfit : r - minRate;
            if(r < minRate) minRate = r;
        } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
            r = in.nextInt();
            maxProfit = (maxProfit > r - minRate)? maxProfit : r - minRate;
            if(r < minRate) minRate = r;
        } {
            r = in.nextInt();
            maxProfit = (maxProfit > r - minRate)? maxProfit : r - minRate;
            if(r < minRate) minRate = r;
        } r = in.nextInt() r in.nextInt() in.nextInt in maxProfit = (maxProfit > r - minRate)? maxProfit : r - minRate maxProfit (maxProfit > r - minRate)? maxProfit : r - minRate (maxProfit > r - minRate) maxProfit r - minRate r minRate maxProfit r - minRate r minRate if(r < minRate) minRate = r; r < minRate r minRate minRate = r minRate r System.out.println(maxProfit) System.out.println System.out System System.out maxProfit String[] args args public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int minRate;
        int maxProfit = Integer.MIN_VALUE;
        int r = in.nextInt();
        minRate = r;

        for (int i = 1; i < n; i++) {
            r = in.nextInt();
            maxProfit = (maxProfit > r - minRate)? maxProfit : r - minRate;
            if(r < minRate) minRate = r;
        }
        System.out.println(maxProfit);
    }
} public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int minRate;
        int maxProfit = Integer.MIN_VALUE;
        int r = in.nextInt();
        minRate = r;

        for (int i = 1; i < n; i++) {
            r = in.nextInt();
            maxProfit = (maxProfit > r - minRate)? maxProfit : r - minRate;
            if(r < minRate) minRate = r;
        }
        System.out.println(maxProfit);
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int minRate;
        int maxProfit = Integer.MIN_VALUE;
        int r = in.nextInt();
        minRate = r;

        for (int i = 1; i < n; i++) {
            r = in.nextInt();
            maxProfit = (maxProfit > r - minRate)? maxProfit : r - minRate;
            if(r < minRate) minRate = r;
        }
        System.out.println(maxProfit);
    }
}