import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
 
    public static void main(String[] args) {
        int max = -BIG_NUM, min = BIG_NUM;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        try {
            int N = Integer.parseInt(br.readLine());
 
            for(int loop = 0; loop < N; loop++){
                int tmp = Integer.parseInt(br.readLine());
                max = Math.max(max, tmp - min);
                min = Math.min(min, tmp);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
 
        System.out.println(max);
    }
} import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.BufferedReader; BufferedReader java.io public class Main {
 
    public static final int BIG_NUM  = 2000000000;
 
    public static void main(String[] args) {
        int max = -BIG_NUM, min = BIG_NUM;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        try {
            int N = Integer.parseInt(br.readLine());
 
            for(int loop = 0; loop < N; loop++){
                int tmp = Integer.parseInt(br.readLine());
                max = Math.max(max, tmp - min);
                min = Math.min(min, tmp);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
 
        System.out.println(max);
    }
} Main public static final int BIG_NUM  = 2000000000; BIG_NUM 2000000000 public static void main(String[] args) {
        int max = -BIG_NUM, min = BIG_NUM;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        try {
            int N = Integer.parseInt(br.readLine());
 
            for(int loop = 0; loop < N; loop++){
                int tmp = Integer.parseInt(br.readLine());
                max = Math.max(max, tmp - min);
                min = Math.min(min, tmp);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
 
        System.out.println(max);
    } main {
        int max = -BIG_NUM, min = BIG_NUM;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        try {
            int N = Integer.parseInt(br.readLine());
 
            for(int loop = 0; loop < N; loop++){
                int tmp = Integer.parseInt(br.readLine());
                max = Math.max(max, tmp - min);
                min = Math.min(min, tmp);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
 
        System.out.println(max);
    } int max = -BIG_NUM max -BIG_NUM BIG_NUM min = BIG_NUM; min BIG_NUM BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) try {
            int N = Integer.parseInt(br.readLine());
 
            for(int loop = 0; loop < N; loop++){
                int tmp = Integer.parseInt(br.readLine());
                max = Math.max(max, tmp - min);
                min = Math.min(min, tmp);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } IOException e {
            e.printStackTrace();
        } e.printStackTrace() e.printStackTrace e {
            int N = Integer.parseInt(br.readLine());
 
            for(int loop = 0; loop < N; loop++){
                int tmp = Integer.parseInt(br.readLine());
                max = Math.max(max, tmp - min);
                min = Math.min(min, tmp);
            }
        } int N = Integer.parseInt(br.readLine()); N Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for(int loop = 0; loop < N; loop++){
                int tmp = Integer.parseInt(br.readLine());
                max = Math.max(max, tmp - min);
                min = Math.min(min, tmp);
            } int loop = 0; int loop = 0; loop 0 loop < N loop N loop++ loop++ loop {
                int tmp = Integer.parseInt(br.readLine());
                max = Math.max(max, tmp - min);
                min = Math.min(min, tmp);
            } {
                int tmp = Integer.parseInt(br.readLine());
                max = Math.max(max, tmp - min);
                min = Math.min(min, tmp);
            } int tmp = Integer.parseInt(br.readLine()); tmp Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br max = Math.max(max, tmp - min) max Math.max(max, tmp - min) Math.max Math max tmp - min tmp min min = Math.min(min, tmp) min Math.min(min, tmp) Math.min Math min tmp System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main {
 
    public static final int BIG_NUM  = 2000000000;
 
    public static void main(String[] args) {
        int max = -BIG_NUM, min = BIG_NUM;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        try {
            int N = Integer.parseInt(br.readLine());
 
            for(int loop = 0; loop < N; loop++){
                int tmp = Integer.parseInt(br.readLine());
                max = Math.max(max, tmp - min);
                min = Math.min(min, tmp);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
 
        System.out.println(max);
    }
} public class Main {
 
    public static final int BIG_NUM  = 2000000000;
 
    public static void main(String[] args) {
        int max = -BIG_NUM, min = BIG_NUM;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        try {
            int N = Integer.parseInt(br.readLine());
 
            for(int loop = 0; loop < N; loop++){
                int tmp = Integer.parseInt(br.readLine());
                max = Math.max(max, tmp - min);
                min = Math.min(min, tmp);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
 
        System.out.println(max);
    }
} Main
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
 
    public static void main(String[] args) {
        int max = -BIG_NUM, min = BIG_NUM;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        try {
            int N = Integer.parseInt(br.readLine());
 
            for(int loop = 0; loop < N; loop++){
                int tmp = Integer.parseInt(br.readLine());
                max = Math.max(max, tmp - min);
                min = Math.min(min, tmp);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
 
        System.out.println(max);
    }
}
