import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int max = Integer.MIN_VALUE;
        int prospectMin = 0;
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(br.readLine());
            if (i == 0) {
                prospectMin = a;
                continue;
            }
            int profit = a - prospectMin;
            if (profit > max) {
                max = profit;
            }
            if (a < prospectMin) {
                prospectMin = a;
            }
        }
        System.out.println(max);

    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int max = Integer.MIN_VALUE;
        int prospectMin = 0;
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(br.readLine());
            if (i == 0) {
                prospectMin = a;
                continue;
            }
            int profit = a - prospectMin;
            if (profit > max) {
                max = profit;
            }
            if (a < prospectMin) {
                prospectMin = a;
            }
        }
        System.out.println(max);

    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int max = Integer.MIN_VALUE;
        int prospectMin = 0;
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(br.readLine());
            if (i == 0) {
                prospectMin = a;
                continue;
            }
            int profit = a - prospectMin;
            if (profit > max) {
                max = profit;
            }
            if (a < prospectMin) {
                prospectMin = a;
            }
        }
        System.out.println(max);

    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int max = Integer.MIN_VALUE;
        int prospectMin = 0;
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(br.readLine());
            if (i == 0) {
                prospectMin = a;
                continue;
            }
            int profit = a - prospectMin;
            if (profit > max) {
                max = profit;
            }
            if (a < prospectMin) {
                prospectMin = a;
            }
        }
        System.out.println(max);

    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int max = Integer.MIN_VALUE; max Integer.MIN_VALUE Integer Integer.MIN_VALUE int prospectMin = 0; prospectMin 0 for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(br.readLine());
            if (i == 0) {
                prospectMin = a;
                continue;
            }
            int profit = a - prospectMin;
            if (profit > max) {
                max = profit;
            }
            if (a < prospectMin) {
                prospectMin = a;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int a = Integer.parseInt(br.readLine());
            if (i == 0) {
                prospectMin = a;
                continue;
            }
            int profit = a - prospectMin;
            if (profit > max) {
                max = profit;
            }
            if (a < prospectMin) {
                prospectMin = a;
            }
        } {
            int a = Integer.parseInt(br.readLine());
            if (i == 0) {
                prospectMin = a;
                continue;
            }
            int profit = a - prospectMin;
            if (profit > max) {
                max = profit;
            }
            if (a < prospectMin) {
                prospectMin = a;
            }
        } int a = Integer.parseInt(br.readLine()); a Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br if (i == 0) {
                prospectMin = a;
                continue;
            } i == 0 i 0 {
                prospectMin = a;
                continue;
            } prospectMin = a prospectMin a continue; int profit = a - prospectMin; profit a - prospectMin a prospectMin if (profit > max) {
                max = profit;
            } profit > max profit max {
                max = profit;
            } max = profit max profit if (a < prospectMin) {
                prospectMin = a;
            } a < prospectMin a prospectMin {
                prospectMin = a;
            } prospectMin = a prospectMin a System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int max = Integer.MIN_VALUE;
        int prospectMin = 0;
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(br.readLine());
            if (i == 0) {
                prospectMin = a;
                continue;
            }
            int profit = a - prospectMin;
            if (profit > max) {
                max = profit;
            }
            if (a < prospectMin) {
                prospectMin = a;
            }
        }
        System.out.println(max);

    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int max = Integer.MIN_VALUE;
        int prospectMin = 0;
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(br.readLine());
            if (i == 0) {
                prospectMin = a;
                continue;
            }
            int profit = a - prospectMin;
            if (profit > max) {
                max = profit;
            }
            if (a < prospectMin) {
                prospectMin = a;
            }
        }
        System.out.println(max);

    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int max = Integer.MIN_VALUE;
        int prospectMin = 0;
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(br.readLine());
            if (i == 0) {
                prospectMin = a;
                continue;
            }
            int profit = a - prospectMin;
            if (profit > max) {
                max = profit;
            }
            if (a < prospectMin) {
                prospectMin = a;
            }
        }
        System.out.println(max);

    }
}