import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int size = scan.nextInt(), min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
        for(int i = 0; i < size; i++){
            int val = scan.nextInt();
            if(max < val - min) max = val - min;
            if(val < min) min = val;
        }
        System.out.println(max);
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int size = scan.nextInt(), min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
        for(int i = 0; i < size; i++){
            int val = scan.nextInt();
            if(max < val - min) max = val - min;
            if(val < min) min = val;
        }
        System.out.println(max);
    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int size = scan.nextInt(), min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
        for(int i = 0; i < size; i++){
            int val = scan.nextInt();
            if(max < val - min) max = val - min;
            if(val < min) min = val;
        }
        System.out.println(max);
    } main {
        Scanner scan = new Scanner(System.in);
        int size = scan.nextInt(), min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
        for(int i = 0; i < size; i++){
            int val = scan.nextInt();
            if(max < val - min) max = val - min;
            if(val < min) min = val;
        }
        System.out.println(max);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int size = scan.nextInt() size scan.nextInt() scan.nextInt scan min = Integer.MAX_VALUE min Integer.MAX_VALUE Integer Integer.MAX_VALUE max = Integer.MIN_VALUE; max Integer.MIN_VALUE Integer Integer.MIN_VALUE for(int i = 0; i < size; i++){
            int val = scan.nextInt();
            if(max < val - min) max = val - min;
            if(val < min) min = val;
        } int i = 0; int i = 0; i 0 i < size i size i++ i++ i {
            int val = scan.nextInt();
            if(max < val - min) max = val - min;
            if(val < min) min = val;
        } {
            int val = scan.nextInt();
            if(max < val - min) max = val - min;
            if(val < min) min = val;
        } int val = scan.nextInt(); val scan.nextInt() scan.nextInt scan if(max < val - min) max = val - min; max < val - min max val - min val min max = val - min max val - min val min if(val < min) min = val; val < min val min min = val min val 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 scan = new Scanner(System.in);
        int size = scan.nextInt(), min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
        for(int i = 0; i < size; i++){
            int val = scan.nextInt();
            if(max < val - min) max = val - min;
            if(val < min) min = val;
        }
        System.out.println(max);
    }
} public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int size = scan.nextInt(), min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
        for(int i = 0; i < size; i++){
            int val = scan.nextInt();
            if(max < val - min) max = val - min;
            if(val < min) min = val;
        }
        System.out.println(max);
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int size = scan.nextInt(), min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
        for(int i = 0; i < size; i++){
            int val = scan.nextInt();
            if(max < val - min) max = val - min;
            if(val < min) min = val;
        }
        System.out.println(max);
    }
}