import java.util.*;
public class Main {

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max_profit = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i)
        {
            int data = sc.nextInt();
            int profit = data - min;
            if (profit > max_profit)
            {
                max_profit = profit;
            }
            if (data < min)
            {
                min = data;
            }
        }
        System.out.println(max_profit);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max_profit = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i)
        {
            int data = sc.nextInt();
            int profit = data - min;
            if (profit > max_profit)
            {
                max_profit = profit;
            }
            if (data < min)
            {
                min = data;
            }
        }
        System.out.println(max_profit);
    }
} Main public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max_profit = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i)
        {
            int data = sc.nextInt();
            int profit = data - min;
            if (profit > max_profit)
            {
                max_profit = profit;
            }
            if (data < min)
            {
                min = data;
            }
        }
        System.out.println(max_profit);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max_profit = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i)
        {
            int data = sc.nextInt();
            int profit = data - min;
            if (profit > max_profit)
            {
                max_profit = profit;
            }
            if (data < min)
            {
                min = data;
            }
        }
        System.out.println(max_profit);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int max_profit = Integer.MIN_VALUE; max_profit Integer.MIN_VALUE Integer Integer.MIN_VALUE int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 0; i < n; ++i)
        {
            int data = sc.nextInt();
            int profit = data - min;
            if (profit > max_profit)
            {
                max_profit = profit;
            }
            if (data < min)
            {
                min = data;
            }
        } int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
            int data = sc.nextInt();
            int profit = data - min;
            if (profit > max_profit)
            {
                max_profit = profit;
            }
            if (data < min)
            {
                min = data;
            }
        } {
            int data = sc.nextInt();
            int profit = data - min;
            if (profit > max_profit)
            {
                max_profit = profit;
            }
            if (data < min)
            {
                min = data;
            }
        } int data = sc.nextInt(); data sc.nextInt() sc.nextInt sc int profit = data - min; profit data - min data min if (profit > max_profit)
            {
                max_profit = profit;
            } profit > max_profit profit max_profit {
                max_profit = profit;
            } max_profit = profit max_profit profit if (data < min)
            {
                min = data;
            } data < min data min {
                min = data;
            } min = data min data System.out.println(max_profit) System.out.println System.out System System.out max_profit String[] args args public class Main {

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max_profit = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i)
        {
            int data = sc.nextInt();
            int profit = data - min;
            if (profit > max_profit)
            {
                max_profit = profit;
            }
            if (data < min)
            {
                min = data;
            }
        }
        System.out.println(max_profit);
    }
} public class Main {

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max_profit = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i)
        {
            int data = sc.nextInt();
            int profit = data - min;
            if (profit > max_profit)
            {
                max_profit = profit;
            }
            if (data < min)
            {
                min = data;
            }
        }
        System.out.println(max_profit);
    }
} Main
import java.util.*;
public class Main {

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max_profit = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i)
        {
            int data = sc.nextInt();
            int profit = data - min;
            if (profit > max_profit)
            {
                max_profit = profit;
            }
            if (data < min)
            {
                min = data;
            }
        }
        System.out.println(max_profit);
    }
}