import java.util.*;
                   
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int[] R = new int[t];
        int i, min, bnf;
        for(i=0; i<t; i++) R[i] = sc.nextInt();
        min = R[0];
        bnf = Integer.MIN_VALUE;
        for(i=1; i<t; i++){
            bnf = Math.max(bnf, R[i]-min);
            min = Math.min(min, R[i]);
        }
                    
        System.out.println(bnf);
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int[] R = new int[t];
        int i, min, bnf;
        for(i=0; i<t; i++) R[i] = sc.nextInt();
        min = R[0];
        bnf = Integer.MIN_VALUE;
        for(i=1; i<t; i++){
            bnf = Math.max(bnf, R[i]-min);
            min = Math.min(min, R[i]);
        }
                    
        System.out.println(bnf);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int[] R = new int[t];
        int i, min, bnf;
        for(i=0; i<t; i++) R[i] = sc.nextInt();
        min = R[0];
        bnf = Integer.MIN_VALUE;
        for(i=1; i<t; i++){
            bnf = Math.max(bnf, R[i]-min);
            min = Math.min(min, R[i]);
        }
                    
        System.out.println(bnf);
    } main {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int[] R = new int[t];
        int i, min, bnf;
        for(i=0; i<t; i++) R[i] = sc.nextInt();
        min = R[0];
        bnf = Integer.MIN_VALUE;
        for(i=1; i<t; i++){
            bnf = Math.max(bnf, R[i]-min);
            min = Math.min(min, R[i]);
        }
                    
        System.out.println(bnf);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int t = sc.nextInt(); t sc.nextInt() sc.nextInt sc int[] R = new int[t]; R new int[t] t int i i min min bnf; bnf for(i=0; i<t; i++) R[i] = sc.nextInt(); i=0; i=0 i 0 i<t i t i++ i++ i R[i] = sc.nextInt(); R[i] = sc.nextInt() R[i] R i sc.nextInt() sc.nextInt sc min = R[0] min R[0] R 0 bnf = Integer.MIN_VALUE bnf Integer.MIN_VALUE Integer Integer.MIN_VALUE for(i=1; i<t; i++){
            bnf = Math.max(bnf, R[i]-min);
            min = Math.min(min, R[i]);
        } i=1; i=1 i 1 i<t i t i++ i++ i {
            bnf = Math.max(bnf, R[i]-min);
            min = Math.min(min, R[i]);
        } {
            bnf = Math.max(bnf, R[i]-min);
            min = Math.min(min, R[i]);
        } bnf = Math.max(bnf, R[i]-min) bnf Math.max(bnf, R[i]-min) Math.max Math bnf R[i]-min R[i] R i min min = Math.min(min, R[i]) min Math.min(min, R[i]) Math.min Math min R[i] R i System.out.println(bnf) System.out.println System.out System System.out bnf String[] args args
import java.util.*;
                   
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int[] R = new int[t];
        int i, min, bnf;
        for(i=0; i<t; i++) R[i] = sc.nextInt();
        min = R[0];
        bnf = Integer.MIN_VALUE;
        for(i=1; i<t; i++){
            bnf = Math.max(bnf, R[i]-min);
            min = Math.min(min, R[i]);
        }
                    
        System.out.println(bnf);
    }
}