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

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

    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int answer =  Integer.MIN_VALUE;
        int min = scan.nextInt();
        for(int x = 0; x < n - 1; x++){
            int r = scan.nextInt();
            answer = Math.max(answer, r - min);
            min = Math.min(min, r);
        }
        System.out.println(answer);

    } main {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int answer =  Integer.MIN_VALUE;
        int min = scan.nextInt();
        for(int x = 0; x < n - 1; x++){
            int r = scan.nextInt();
            answer = Math.max(answer, r - min);
            min = Math.min(min, r);
        }
        System.out.println(answer);

    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int answer =  Integer.MIN_VALUE; answer Integer.MIN_VALUE Integer Integer.MIN_VALUE int min = scan.nextInt(); min scan.nextInt() scan.nextInt scan for(int x = 0; x < n - 1; x++){
            int r = scan.nextInt();
            answer = Math.max(answer, r - min);
            min = Math.min(min, r);
        } int x = 0; int x = 0; x 0 x < n - 1 x n - 1 n 1 x++ x++ x {
            int r = scan.nextInt();
            answer = Math.max(answer, r - min);
            min = Math.min(min, r);
        } {
            int r = scan.nextInt();
            answer = Math.max(answer, r - min);
            min = Math.min(min, r);
        } int r = scan.nextInt(); r scan.nextInt() scan.nextInt scan answer = Math.max(answer, r - min) answer Math.max(answer, r - min) Math.max Math answer r - min r min min = Math.min(min, r) min Math.min(min, r) Math.min Math min r System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int answer =  Integer.MIN_VALUE;
        int min = scan.nextInt();
        for(int x = 0; x < n - 1; x++){
            int r = scan.nextInt();
            answer = Math.max(answer, r - min);
            min = Math.min(min, r);
        }
        System.out.println(answer);

    }
} public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int answer =  Integer.MIN_VALUE;
        int min = scan.nextInt();
        for(int x = 0; x < n - 1; x++){
            int r = scan.nextInt();
            answer = Math.max(answer, r - min);
            min = Math.min(min, r);
        }
        System.out.println(answer);

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

    }
}
