import java.util.Scanner;

public class Main {

    public int size;
    public int[] mx;

    public void scan() {
        Scanner sc = new Scanner(System.in);
        this.size = sc.nextInt();
        this.mx = new int[this.size];
        for (int i = 0; i < this.size; i++) {
            this.mx[i] = sc.nextInt();
        }
    }

    public void task() {
        int min = this.mx[0];
        int max = this.mx[1] - this.mx[0];
        for(int i = 1; i < this.size; i++){
            if(max < this.mx[i] - min){ max = this.mx[i] - min; }
            if(min > this.mx[i]){ min = this.mx[i]; }
        }
        System.out.println(max);
    }

    public static void main(String[] args) {
        Main prime = new Main();
        prime.scan();
        prime.task();
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public int size;
    public int[] mx;

    public void scan() {
        Scanner sc = new Scanner(System.in);
        this.size = sc.nextInt();
        this.mx = new int[this.size];
        for (int i = 0; i < this.size; i++) {
            this.mx[i] = sc.nextInt();
        }
    }

    public void task() {
        int min = this.mx[0];
        int max = this.mx[1] - this.mx[0];
        for(int i = 1; i < this.size; i++){
            if(max < this.mx[i] - min){ max = this.mx[i] - min; }
            if(min > this.mx[i]){ min = this.mx[i]; }
        }
        System.out.println(max);
    }

    public static void main(String[] args) {
        Main prime = new Main();
        prime.scan();
        prime.task();
    }
} Main public int size; size public int[] mx; mx public void scan() {
        Scanner sc = new Scanner(System.in);
        this.size = sc.nextInt();
        this.mx = new int[this.size];
        for (int i = 0; i < this.size; i++) {
            this.mx[i] = sc.nextInt();
        }
    } scan {
        Scanner sc = new Scanner(System.in);
        this.size = sc.nextInt();
        this.mx = new int[this.size];
        for (int i = 0; i < this.size; i++) {
            this.mx[i] = sc.nextInt();
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) this.size = sc.nextInt() this.size this this.size sc.nextInt() sc.nextInt sc this.mx = new int[this.size] this.mx this this.mx new int[this.size] this.size this this.size for (int i = 0; i < this.size; i++) {
            this.mx[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < this.size i this.size this this.size i++ i++ i {
            this.mx[i] = sc.nextInt();
        } {
            this.mx[i] = sc.nextInt();
        } this.mx[i] = sc.nextInt() this.mx[i] this.mx this this.mx i sc.nextInt() sc.nextInt sc public void task() {
        int min = this.mx[0];
        int max = this.mx[1] - this.mx[0];
        for(int i = 1; i < this.size; i++){
            if(max < this.mx[i] - min){ max = this.mx[i] - min; }
            if(min > this.mx[i]){ min = this.mx[i]; }
        }
        System.out.println(max);
    } task {
        int min = this.mx[0];
        int max = this.mx[1] - this.mx[0];
        for(int i = 1; i < this.size; i++){
            if(max < this.mx[i] - min){ max = this.mx[i] - min; }
            if(min > this.mx[i]){ min = this.mx[i]; }
        }
        System.out.println(max);
    } int min = this.mx[0]; min this.mx[0] this.mx this this.mx 0 int max = this.mx[1] - this.mx[0]; max this.mx[1] - this.mx[0] this.mx[1] this.mx this this.mx 1 this.mx[0] this.mx this this.mx 0 for(int i = 1; i < this.size; i++){
            if(max < this.mx[i] - min){ max = this.mx[i] - min; }
            if(min > this.mx[i]){ min = this.mx[i]; }
        } int i = 1; int i = 1; i 1 i < this.size i this.size this this.size i++ i++ i {
            if(max < this.mx[i] - min){ max = this.mx[i] - min; }
            if(min > this.mx[i]){ min = this.mx[i]; }
        } {
            if(max < this.mx[i] - min){ max = this.mx[i] - min; }
            if(min > this.mx[i]){ min = this.mx[i]; }
        } if(max < this.mx[i] - min){ max = this.mx[i] - min; } max < this.mx[i] - min max this.mx[i] - min this.mx[i] this.mx this this.mx i min { max = this.mx[i] - min; } max = this.mx[i] - min max this.mx[i] - min this.mx[i] this.mx this this.mx i min if(min > this.mx[i]){ min = this.mx[i]; } min > this.mx[i] min this.mx[i] this.mx this this.mx i { min = this.mx[i]; } min = this.mx[i] min this.mx[i] this.mx this this.mx i System.out.println(max) System.out.println System.out System System.out max public static void main(String[] args) {
        Main prime = new Main();
        prime.scan();
        prime.task();
    } main {
        Main prime = new Main();
        prime.scan();
        prime.task();
    } Main prime = new Main(); prime new Main() prime.scan() prime.scan prime prime.task() prime.task prime String[] args args public class Main {

    public int size;
    public int[] mx;

    public void scan() {
        Scanner sc = new Scanner(System.in);
        this.size = sc.nextInt();
        this.mx = new int[this.size];
        for (int i = 0; i < this.size; i++) {
            this.mx[i] = sc.nextInt();
        }
    }

    public void task() {
        int min = this.mx[0];
        int max = this.mx[1] - this.mx[0];
        for(int i = 1; i < this.size; i++){
            if(max < this.mx[i] - min){ max = this.mx[i] - min; }
            if(min > this.mx[i]){ min = this.mx[i]; }
        }
        System.out.println(max);
    }

    public static void main(String[] args) {
        Main prime = new Main();
        prime.scan();
        prime.task();
    }
} public class Main {

    public int size;
    public int[] mx;

    public void scan() {
        Scanner sc = new Scanner(System.in);
        this.size = sc.nextInt();
        this.mx = new int[this.size];
        for (int i = 0; i < this.size; i++) {
            this.mx[i] = sc.nextInt();
        }
    }

    public void task() {
        int min = this.mx[0];
        int max = this.mx[1] - this.mx[0];
        for(int i = 1; i < this.size; i++){
            if(max < this.mx[i] - min){ max = this.mx[i] - min; }
            if(min > this.mx[i]){ min = this.mx[i]; }
        }
        System.out.println(max);
    }

    public static void main(String[] args) {
        Main prime = new Main();
        prime.scan();
        prime.task();
    }
} Main
import java.util.Scanner;

public class Main {

    public int size;
    public int[] mx;

    public void scan() {
        Scanner sc = new Scanner(System.in);
        this.size = sc.nextInt();
        this.mx = new int[this.size];
        for (int i = 0; i < this.size; i++) {
            this.mx[i] = sc.nextInt();
        }
    }

    public void task() {
        int min = this.mx[0];
        int max = this.mx[1] - this.mx[0];
        for(int i = 1; i < this.size; i++){
            if(max < this.mx[i] - min){ max = this.mx[i] - min; }
            if(min > this.mx[i]){ min = this.mx[i]; }
        }
        System.out.println(max);
    }

    public static void main(String[] args) {
        Main prime = new Main();
        prime.scan();
        prime.task();
    }
}
