import java.io.*;
import java.util.*;

class Main{
    void run() throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int num = Integer.parseInt(in.readLine());
        int[] menber = new int[num];
        for(int i = 0;i < num;i++){
            menber[i] = Integer.parseInt(in.readLine());
        }
        int count = 0;
        int ans = -2000000000;
        int minv = menber[0];
        for(int i = 1;i < num;i++){
            if(ans <= menber[i] - minv)
                ans = menber[i] - minv;
            if(minv >= menber[i])
                minv = menber[i];
        }
        System.out.println(ans);
    }
    public static void main(String[] args) throws IOException{
        Main ma = new Main();
        ma.run();
    }
} import java.io.*; io.* java import java.util.*; util.* java class Main{
    void run() throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int num = Integer.parseInt(in.readLine());
        int[] menber = new int[num];
        for(int i = 0;i < num;i++){
            menber[i] = Integer.parseInt(in.readLine());
        }
        int count = 0;
        int ans = -2000000000;
        int minv = menber[0];
        for(int i = 1;i < num;i++){
            if(ans <= menber[i] - minv)
                ans = menber[i] - minv;
            if(minv >= menber[i])
                minv = menber[i];
        }
        System.out.println(ans);
    }
    public static void main(String[] args) throws IOException{
        Main ma = new Main();
        ma.run();
    }
} Main void run() throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int num = Integer.parseInt(in.readLine());
        int[] menber = new int[num];
        for(int i = 0;i < num;i++){
            menber[i] = Integer.parseInt(in.readLine());
        }
        int count = 0;
        int ans = -2000000000;
        int minv = menber[0];
        for(int i = 1;i < num;i++){
            if(ans <= menber[i] - minv)
                ans = menber[i] - minv;
            if(minv >= menber[i])
                minv = menber[i];
        }
        System.out.println(ans);
    } run {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int num = Integer.parseInt(in.readLine());
        int[] menber = new int[num];
        for(int i = 0;i < num;i++){
            menber[i] = Integer.parseInt(in.readLine());
        }
        int count = 0;
        int ans = -2000000000;
        int minv = menber[0];
        for(int i = 1;i < num;i++){
            if(ans <= menber[i] - minv)
                ans = menber[i] - minv;
            if(minv >= menber[i])
                minv = menber[i];
        }
        System.out.println(ans);
    } BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) int num = Integer.parseInt(in.readLine()); num Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in int[] menber = new int[num]; menber new int[num] num for(int i = 0;i < num;i++){
            menber[i] = Integer.parseInt(in.readLine());
        } int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
            menber[i] = Integer.parseInt(in.readLine());
        } {
            menber[i] = Integer.parseInt(in.readLine());
        } menber[i] = Integer.parseInt(in.readLine()) menber[i] menber i Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in int count = 0; count 0 int ans = -2000000000; ans -2000000000 2000000000 int minv = menber[0]; minv menber[0] menber 0 for(int i = 1;i < num;i++){
            if(ans <= menber[i] - minv)
                ans = menber[i] - minv;
            if(minv >= menber[i])
                minv = menber[i];
        } int i = 1; int i = 1; i 1 i < num i num i++ i++ i {
            if(ans <= menber[i] - minv)
                ans = menber[i] - minv;
            if(minv >= menber[i])
                minv = menber[i];
        } {
            if(ans <= menber[i] - minv)
                ans = menber[i] - minv;
            if(minv >= menber[i])
                minv = menber[i];
        } if(ans <= menber[i] - minv)
                ans = menber[i] - minv; ans <= menber[i] - minv ans menber[i] - minv menber[i] menber i minv ans = menber[i] - minv ans menber[i] - minv menber[i] menber i minv if(minv >= menber[i])
                minv = menber[i]; minv >= menber[i] minv menber[i] menber i minv = menber[i] minv menber[i] menber i System.out.println(ans) System.out.println System.out System System.out ans public static void main(String[] args) throws IOException{
        Main ma = new Main();
        ma.run();
    } main {
        Main ma = new Main();
        ma.run();
    } Main ma = new Main(); ma new Main() ma.run() ma.run ma String[] args args
import java.io.*;
import java.util.*;

class Main{
    void run() throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int num = Integer.parseInt(in.readLine());
        int[] menber = new int[num];
        for(int i = 0;i < num;i++){
            menber[i] = Integer.parseInt(in.readLine());
        }
        int count = 0;
        int ans = -2000000000;
        int minv = menber[0];
        for(int i = 1;i < num;i++){
            if(ans <= menber[i] - minv)
                ans = menber[i] - minv;
            if(minv >= menber[i])
                minv = menber[i];
        }
        System.out.println(ans);
    }
    public static void main(String[] args) throws IOException{
        Main ma = new Main();
        ma.run();
    }
}