import java.util.*;

public class Main {
    public static void main(String args[]) {
        // input

        int num;

        Scanner inp = new Scanner(System.in);

        num = inp.nextInt();

        int min = inp.nextInt();
        int max = (int) -(Math.pow(10,9));

        for (int i = 0; i < num-1; i++) {
            int r = inp.nextInt();
            max = Math.max(max, r-min);
            min = Math.min(min,r);
        }

        System.out.println(max);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String args[]) {
        // input

        int num;

        Scanner inp = new Scanner(System.in);

        num = inp.nextInt();

        int min = inp.nextInt();
        int max = (int) -(Math.pow(10,9));

        for (int i = 0; i < num-1; i++) {
            int r = inp.nextInt();
            max = Math.max(max, r-min);
            min = Math.min(min,r);
        }

        System.out.println(max);
    }
} Main public static void main(String args[]) {
        // input

        int num;

        Scanner inp = new Scanner(System.in);

        num = inp.nextInt();

        int min = inp.nextInt();
        int max = (int) -(Math.pow(10,9));

        for (int i = 0; i < num-1; i++) {
            int r = inp.nextInt();
            max = Math.max(max, r-min);
            min = Math.min(min,r);
        }

        System.out.println(max);
    } main {
        // input

        int num;

        Scanner inp = new Scanner(System.in);

        num = inp.nextInt();

        int min = inp.nextInt();
        int max = (int) -(Math.pow(10,9));

        for (int i = 0; i < num-1; i++) {
            int r = inp.nextInt();
            max = Math.max(max, r-min);
            min = Math.min(min,r);
        }

        System.out.println(max);
    } int num; num Scanner inp = new Scanner(System.in); inp new Scanner(System.in) num = inp.nextInt() num inp.nextInt() inp.nextInt inp int min = inp.nextInt(); min inp.nextInt() inp.nextInt inp int max = (int) -(Math.pow(10,9)); max (int) -(Math.pow(10,9)) (Math.pow(10,9)) Math.pow Math 10 9 for (int i = 0; i < num-1; i++) {
            int r = inp.nextInt();
            max = Math.max(max, r-min);
            min = Math.min(min,r);
        } int i = 0; int i = 0; i 0 i < num-1 i num-1 num 1 i++ i++ i {
            int r = inp.nextInt();
            max = Math.max(max, r-min);
            min = Math.min(min,r);
        } {
            int r = inp.nextInt();
            max = Math.max(max, r-min);
            min = Math.min(min,r);
        } int r = inp.nextInt(); r inp.nextInt() inp.nextInt inp max = Math.max(max, r-min) max Math.max(max, r-min) Math.max Math max r-min r min min = Math.min(min,r) min Math.min(min,r) Math.min Math min r 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[]) {
        // input

        int num;

        Scanner inp = new Scanner(System.in);

        num = inp.nextInt();

        int min = inp.nextInt();
        int max = (int) -(Math.pow(10,9));

        for (int i = 0; i < num-1; i++) {
            int r = inp.nextInt();
            max = Math.max(max, r-min);
            min = Math.min(min,r);
        }

        System.out.println(max);
    }
} public class Main {
    public static void main(String args[]) {
        // input

        int num;

        Scanner inp = new Scanner(System.in);

        num = inp.nextInt();

        int min = inp.nextInt();
        int max = (int) -(Math.pow(10,9));

        for (int i = 0; i < num-1; i++) {
            int r = inp.nextInt();
            max = Math.max(max, r-min);
            min = Math.min(min,r);
        }

        System.out.println(max);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String args[]) {
        // input

        int num;

        Scanner inp = new Scanner(System.in);

        num = inp.nextInt();

        int min = inp.nextInt();
        int max = (int) -(Math.pow(10,9));

        for (int i = 0; i < num-1; i++) {
            int r = inp.nextInt();
            max = Math.max(max, r-min);
            min = Math.min(min,r);
        }

        System.out.println(max);
    }
}
