
import java.io.IOException;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);

        int loopCount = Integer.parseInt(scanner.next());
        Integer cheaper = null;
        Integer maximum = null;
        for (int i = 0; i < loopCount; i++) {
            int current = Integer.parseInt(scanner.next());
            if (i == 0) {
                cheaper = current;
                continue;
            }

            int diff = current - cheaper;
            if (maximum == null || diff > maximum) {
                maximum = diff;
            }
            if (current < cheaper) {
                cheaper = current;
            }
        }

        System.out.println(maximum);
    }
} import java.io.IOException; IOException java.io import java.math.BigInteger; BigInteger java.math import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);

        int loopCount = Integer.parseInt(scanner.next());
        Integer cheaper = null;
        Integer maximum = null;
        for (int i = 0; i < loopCount; i++) {
            int current = Integer.parseInt(scanner.next());
            if (i == 0) {
                cheaper = current;
                continue;
            }

            int diff = current - cheaper;
            if (maximum == null || diff > maximum) {
                maximum = diff;
            }
            if (current < cheaper) {
                cheaper = current;
            }
        }

        System.out.println(maximum);
    }
} Main public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);

        int loopCount = Integer.parseInt(scanner.next());
        Integer cheaper = null;
        Integer maximum = null;
        for (int i = 0; i < loopCount; i++) {
            int current = Integer.parseInt(scanner.next());
            if (i == 0) {
                cheaper = current;
                continue;
            }

            int diff = current - cheaper;
            if (maximum == null || diff > maximum) {
                maximum = diff;
            }
            if (current < cheaper) {
                cheaper = current;
            }
        }

        System.out.println(maximum);
    } main {
        Scanner scanner = new Scanner(System.in);

        int loopCount = Integer.parseInt(scanner.next());
        Integer cheaper = null;
        Integer maximum = null;
        for (int i = 0; i < loopCount; i++) {
            int current = Integer.parseInt(scanner.next());
            if (i == 0) {
                cheaper = current;
                continue;
            }

            int diff = current - cheaper;
            if (maximum == null || diff > maximum) {
                maximum = diff;
            }
            if (current < cheaper) {
                cheaper = current;
            }
        }

        System.out.println(maximum);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int loopCount = Integer.parseInt(scanner.next()); loopCount Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner Integer cheaper = null; cheaper null Integer maximum = null; maximum null for (int i = 0; i < loopCount; i++) {
            int current = Integer.parseInt(scanner.next());
            if (i == 0) {
                cheaper = current;
                continue;
            }

            int diff = current - cheaper;
            if (maximum == null || diff > maximum) {
                maximum = diff;
            }
            if (current < cheaper) {
                cheaper = current;
            }
        } int i = 0; int i = 0; i 0 i < loopCount i loopCount i++ i++ i {
            int current = Integer.parseInt(scanner.next());
            if (i == 0) {
                cheaper = current;
                continue;
            }

            int diff = current - cheaper;
            if (maximum == null || diff > maximum) {
                maximum = diff;
            }
            if (current < cheaper) {
                cheaper = current;
            }
        } {
            int current = Integer.parseInt(scanner.next());
            if (i == 0) {
                cheaper = current;
                continue;
            }

            int diff = current - cheaper;
            if (maximum == null || diff > maximum) {
                maximum = diff;
            }
            if (current < cheaper) {
                cheaper = current;
            }
        } int current = Integer.parseInt(scanner.next()); current Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner if (i == 0) {
                cheaper = current;
                continue;
            } i == 0 i 0 {
                cheaper = current;
                continue;
            } cheaper = current cheaper current continue; int diff = current - cheaper; diff current - cheaper current cheaper if (maximum == null || diff > maximum) {
                maximum = diff;
            } maximum == null || diff > maximum maximum == null maximum null diff > maximum diff maximum {
                maximum = diff;
            } maximum = diff maximum diff if (current < cheaper) {
                cheaper = current;
            } current < cheaper current cheaper {
                cheaper = current;
            } cheaper = current cheaper current System.out.println(maximum) System.out.println System.out System System.out maximum String[] args args public class Main {

    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);

        int loopCount = Integer.parseInt(scanner.next());
        Integer cheaper = null;
        Integer maximum = null;
        for (int i = 0; i < loopCount; i++) {
            int current = Integer.parseInt(scanner.next());
            if (i == 0) {
                cheaper = current;
                continue;
            }

            int diff = current - cheaper;
            if (maximum == null || diff > maximum) {
                maximum = diff;
            }
            if (current < cheaper) {
                cheaper = current;
            }
        }

        System.out.println(maximum);
    }
} public class Main {

    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);

        int loopCount = Integer.parseInt(scanner.next());
        Integer cheaper = null;
        Integer maximum = null;
        for (int i = 0; i < loopCount; i++) {
            int current = Integer.parseInt(scanner.next());
            if (i == 0) {
                cheaper = current;
                continue;
            }

            int diff = current - cheaper;
            if (maximum == null || diff > maximum) {
                maximum = diff;
            }
            if (current < cheaper) {
                cheaper = current;
            }
        }

        System.out.println(maximum);
    }
} Main

import java.io.IOException;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);

        int loopCount = Integer.parseInt(scanner.next());
        Integer cheaper = null;
        Integer maximum = null;
        for (int i = 0; i < loopCount; i++) {
            int current = Integer.parseInt(scanner.next());
            if (i == 0) {
                cheaper = current;
                continue;
            }

            int diff = current - cheaper;
            if (maximum == null || diff > maximum) {
                maximum = diff;
            }
            if (current < cheaper) {
                cheaper = current;
            }
        }

        System.out.println(maximum);
    }
}