import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int max=-1000000000,res,min=0,num;
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            num=sc.nextInt();
            if(i==0){
                min=num;
            }else{
                res=num-min;
                if(res>max){
                    max=res;
                }
                if(min>num){
                    min=num;
                }
            }
        }
        System.out.println(max);
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int max=-1000000000,res,min=0,num;
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            num=sc.nextInt();
            if(i==0){
                min=num;
            }else{
                res=num-min;
                if(res>max){
                    max=res;
                }
                if(min>num){
                    min=num;
                }
            }
        }
        System.out.println(max);
    }
} Main public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int max=-1000000000,res,min=0,num;
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            num=sc.nextInt();
            if(i==0){
                min=num;
            }else{
                res=num-min;
                if(res>max){
                    max=res;
                }
                if(min>num){
                    min=num;
                }
            }
        }
        System.out.println(max);
    } main {
        Scanner sc=new Scanner(System.in);
        int max=-1000000000,res,min=0,num;
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            num=sc.nextInt();
            if(i==0){
                min=num;
            }else{
                res=num-min;
                if(res>max){
                    max=res;
                }
                if(min>num){
                    min=num;
                }
            }
        }
        System.out.println(max);
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int max=-1000000000 max -1000000000 1000000000 res res min=0 min 0 num; num int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc for(int i=0;i<n;i++){
            num=sc.nextInt();
            if(i==0){
                min=num;
            }else{
                res=num-min;
                if(res>max){
                    max=res;
                }
                if(min>num){
                    min=num;
                }
            }
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            num=sc.nextInt();
            if(i==0){
                min=num;
            }else{
                res=num-min;
                if(res>max){
                    max=res;
                }
                if(min>num){
                    min=num;
                }
            }
        } {
            num=sc.nextInt();
            if(i==0){
                min=num;
            }else{
                res=num-min;
                if(res>max){
                    max=res;
                }
                if(min>num){
                    min=num;
                }
            }
        } num=sc.nextInt() num sc.nextInt() sc.nextInt sc if(i==0){
                min=num;
            }else{
                res=num-min;
                if(res>max){
                    max=res;
                }
                if(min>num){
                    min=num;
                }
            } i==0 i 0 {
                min=num;
            } min=num min num {
                res=num-min;
                if(res>max){
                    max=res;
                }
                if(min>num){
                    min=num;
                }
            } res=num-min res num-min num min if(res>max){
                    max=res;
                } res>max res max {
                    max=res;
                } max=res max res if(min>num){
                    min=num;
                } min>num min num {
                    min=num;
                } min=num min num 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){
        Scanner sc=new Scanner(System.in);
        int max=-1000000000,res,min=0,num;
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            num=sc.nextInt();
            if(i==0){
                min=num;
            }else{
                res=num-min;
                if(res>max){
                    max=res;
                }
                if(min>num){
                    min=num;
                }
            }
        }
        System.out.println(max);
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int max=-1000000000,res,min=0,num;
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            num=sc.nextInt();
            if(i==0){
                min=num;
            }else{
                res=num-min;
                if(res>max){
                    max=res;
                }
                if(min>num){
                    min=num;
                }
            }
        }
        System.out.println(max);
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int max=-1000000000,res,min=0,num;
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            num=sc.nextInt();
            if(i==0){
                min=num;
            }else{
                res=num-min;
                if(res>max){
                    max=res;
                }
                if(min>num){
                    min=num;
                }
            }
        }
        System.out.println(max);
    }
}
