

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().start();
    }
    void start(){
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[]a = new int[t];
        for(int i = 0; i < a.length;i++){
        	a[i] = in.nextInt();
        }

        int min = a[0];
        int maxRieki = Integer.MIN_VALUE;
        for(int i = 1; i < a.length; i++){
            int rieki = a[i] - min;
            if(a[i] < min) min = a[i];
            if(rieki > maxRieki) maxRieki = rieki;
        }
        System.out.println(maxRieki);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        new Main().start();
    }
    void start(){
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[]a = new int[t];
        for(int i = 0; i < a.length;i++){
        	a[i] = in.nextInt();
        }

        int min = a[0];
        int maxRieki = Integer.MIN_VALUE;
        for(int i = 1; i < a.length; i++){
            int rieki = a[i] - min;
            if(a[i] < min) min = a[i];
            if(rieki > maxRieki) maxRieki = rieki;
        }
        System.out.println(maxRieki);
    }
} Main public static void main(String[] args) {
        new Main().start();
    } main {
        new Main().start();
    } new Main().start() new Main().start new Main() String[] args args void start(){
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[]a = new int[t];
        for(int i = 0; i < a.length;i++){
        	a[i] = in.nextInt();
        }

        int min = a[0];
        int maxRieki = Integer.MIN_VALUE;
        for(int i = 1; i < a.length; i++){
            int rieki = a[i] - min;
            if(a[i] < min) min = a[i];
            if(rieki > maxRieki) maxRieki = rieki;
        }
        System.out.println(maxRieki);
    } start {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[]a = new int[t];
        for(int i = 0; i < a.length;i++){
        	a[i] = in.nextInt();
        }

        int min = a[0];
        int maxRieki = Integer.MIN_VALUE;
        for(int i = 1; i < a.length; i++){
            int rieki = a[i] - min;
            if(a[i] < min) min = a[i];
            if(rieki > maxRieki) maxRieki = rieki;
        }
        System.out.println(maxRieki);
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int t = in.nextInt(); t in.nextInt() in.nextInt in int[]a = new int[t]; a new int[t] t for(int i = 0; i < a.length;i++){
        	a[i] = in.nextInt();
        } int i = 0; int i = 0; i 0 i < a.length i a.length a a.length i++ i++ i {
        	a[i] = in.nextInt();
        } {
        	a[i] = in.nextInt();
        } a[i] = in.nextInt() a[i] a i in.nextInt() in.nextInt in int min = a[0]; min a[0] a 0 int maxRieki = Integer.MIN_VALUE; maxRieki Integer.MIN_VALUE Integer Integer.MIN_VALUE for(int i = 1; i < a.length; i++){
            int rieki = a[i] - min;
            if(a[i] < min) min = a[i];
            if(rieki > maxRieki) maxRieki = rieki;
        } int i = 1; int i = 1; i 1 i < a.length i a.length a a.length i++ i++ i {
            int rieki = a[i] - min;
            if(a[i] < min) min = a[i];
            if(rieki > maxRieki) maxRieki = rieki;
        } {
            int rieki = a[i] - min;
            if(a[i] < min) min = a[i];
            if(rieki > maxRieki) maxRieki = rieki;
        } int rieki = a[i] - min; rieki a[i] - min a[i] a i min if(a[i] < min) min = a[i]; a[i] < min a[i] a i min min = a[i] min a[i] a i if(rieki > maxRieki) maxRieki = rieki; rieki > maxRieki rieki maxRieki maxRieki = rieki maxRieki rieki System.out.println(maxRieki) System.out.println System.out System System.out maxRieki public class Main {
    public static void main(String[] args) {
        new Main().start();
    }
    void start(){
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[]a = new int[t];
        for(int i = 0; i < a.length;i++){
        	a[i] = in.nextInt();
        }

        int min = a[0];
        int maxRieki = Integer.MIN_VALUE;
        for(int i = 1; i < a.length; i++){
            int rieki = a[i] - min;
            if(a[i] < min) min = a[i];
            if(rieki > maxRieki) maxRieki = rieki;
        }
        System.out.println(maxRieki);
    }
} public class Main {
    public static void main(String[] args) {
        new Main().start();
    }
    void start(){
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[]a = new int[t];
        for(int i = 0; i < a.length;i++){
        	a[i] = in.nextInt();
        }

        int min = a[0];
        int maxRieki = Integer.MIN_VALUE;
        for(int i = 1; i < a.length; i++){
            int rieki = a[i] - min;
            if(a[i] < min) min = a[i];
            if(rieki > maxRieki) maxRieki = rieki;
        }
        System.out.println(maxRieki);
    }
} Main


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().start();
    }
    void start(){
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[]a = new int[t];
        for(int i = 0; i < a.length;i++){
        	a[i] = in.nextInt();
        }

        int min = a[0];
        int maxRieki = Integer.MIN_VALUE;
        for(int i = 1; i < a.length; i++){
            int rieki = a[i] - min;
            if(a[i] < min) min = a[i];
            if(rieki > maxRieki) maxRieki = rieki;
        }
        System.out.println(maxRieki);
    }
}