import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = 0;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            int j = sc.nextInt();//当前数
            if (i == 0) {
                min = j;
            }else{
                max=Math.max(max,j-min);
                min=Math.min(min,j);
            }
        }
        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 n = sc.nextInt();
        int min = 0;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            int j = sc.nextInt();//当前数
            if (i == 0) {
                min = j;
            }else{
                max=Math.max(max,j-min);
                min=Math.min(min,j);
            }
        }
        System.out.println(max);
    }} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = 0;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            int j = sc.nextInt();//当前数
            if (i == 0) {
                min = j;
            }else{
                max=Math.max(max,j-min);
                min=Math.min(min,j);
            }
        }
        System.out.println(max);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = 0;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            int j = sc.nextInt();//当前数
            if (i == 0) {
                min = j;
            }else{
                max=Math.max(max,j-min);
                min=Math.min(min,j);
            }
        }
        System.out.println(max);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int min = 0; min 0 int max = Integer.MIN_VALUE; max Integer.MIN_VALUE Integer Integer.MIN_VALUE for (int i = 0; i < n; i++) {
            int j = sc.nextInt();//当前数
            if (i == 0) {
                min = j;
            }else{
                max=Math.max(max,j-min);
                min=Math.min(min,j);
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int j = sc.nextInt();//当前数
            if (i == 0) {
                min = j;
            }else{
                max=Math.max(max,j-min);
                min=Math.min(min,j);
            }
        } {
            int j = sc.nextInt();//当前数
            if (i == 0) {
                min = j;
            }else{
                max=Math.max(max,j-min);
                min=Math.min(min,j);
            }
        } int j = sc.nextInt(); j sc.nextInt() sc.nextInt sc if (i == 0) {
                min = j;
            }else{
                max=Math.max(max,j-min);
                min=Math.min(min,j);
            } i == 0 i 0 {
                min = j;
            } min = j min j {
                max=Math.max(max,j-min);
                min=Math.min(min,j);
            } max=Math.max(max,j-min) max Math.max(max,j-min) Math.max Math max j-min j min min=Math.min(min,j) min Math.min(min,j) Math.min Math min j 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 n = sc.nextInt();
        int min = 0;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            int j = sc.nextInt();//当前数
            if (i == 0) {
                min = j;
            }else{
                max=Math.max(max,j-min);
                min=Math.min(min,j);
            }
        }
        System.out.println(max);
    }} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = 0;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            int j = sc.nextInt();//当前数
            if (i == 0) {
                min = j;
            }else{
                max=Math.max(max,j-min);
                min=Math.min(min,j);
            }
        }
        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 n = sc.nextInt();
        int min = 0;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            int j = sc.nextInt();//当前数
            if (i == 0) {
                min = j;
            }else{
                max=Math.max(max,j-min);
                min=Math.min(min,j);
            }
        }
        System.out.println(max);
    }}
