import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] price = new int[n];
        int i, j;

        for (i = 0; i < n; i++) {
            price[i] = Integer.parseInt(br.readLine());
        }

        int max = price[1] - price[0];
        int min = price[0] + 1;

        for (i = 0; i < n-1; i++) {
            if (price[i] < min) min = price[i];
            else continue;

            for (j = i+1; j < n; j++) {
                if (price[j] - min > max) {
                    max = price[j] - min;
                }
            }
        }
        System.out.println(max);
    }
} import java.io.*; io.* java class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] price = new int[n];
        int i, j;

        for (i = 0; i < n; i++) {
            price[i] = Integer.parseInt(br.readLine());
        }

        int max = price[1] - price[0];
        int min = price[0] + 1;

        for (i = 0; i < n-1; i++) {
            if (price[i] < min) min = price[i];
            else continue;

            for (j = i+1; j < n; j++) {
                if (price[j] - min > max) {
                    max = price[j] - min;
                }
            }
        }
        System.out.println(max);
    }
} Main public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] price = new int[n];
        int i, j;

        for (i = 0; i < n; i++) {
            price[i] = Integer.parseInt(br.readLine());
        }

        int max = price[1] - price[0];
        int min = price[0] + 1;

        for (i = 0; i < n-1; i++) {
            if (price[i] < min) min = price[i];
            else continue;

            for (j = i+1; j < n; j++) {
                if (price[j] - min > max) {
                    max = price[j] - min;
                }
            }
        }
        System.out.println(max);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] price = new int[n];
        int i, j;

        for (i = 0; i < n; i++) {
            price[i] = Integer.parseInt(br.readLine());
        }

        int max = price[1] - price[0];
        int min = price[0] + 1;

        for (i = 0; i < n-1; i++) {
            if (price[i] < min) min = price[i];
            else continue;

            for (j = i+1; j < n; j++) {
                if (price[j] - min > max) {
                    max = price[j] - min;
                }
            }
        }
        System.out.println(max);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int[] price = new int[n]; price new int[n] n int i i j; j for (i = 0; i < n; i++) {
            price[i] = Integer.parseInt(br.readLine());
        } i = 0; i = 0 i 0 i < n i n i++ i++ i {
            price[i] = Integer.parseInt(br.readLine());
        } {
            price[i] = Integer.parseInt(br.readLine());
        } price[i] = Integer.parseInt(br.readLine()) price[i] price i Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int max = price[1] - price[0]; max price[1] - price[0] price[1] price 1 price[0] price 0 int min = price[0] + 1; min price[0] + 1 price[0] price 0 1 for (i = 0; i < n-1; i++) {
            if (price[i] < min) min = price[i];
            else continue;

            for (j = i+1; j < n; j++) {
                if (price[j] - min > max) {
                    max = price[j] - min;
                }
            }
        } i = 0; i = 0 i 0 i < n-1 i n-1 n 1 i++ i++ i {
            if (price[i] < min) min = price[i];
            else continue;

            for (j = i+1; j < n; j++) {
                if (price[j] - min > max) {
                    max = price[j] - min;
                }
            }
        } {
            if (price[i] < min) min = price[i];
            else continue;

            for (j = i+1; j < n; j++) {
                if (price[j] - min > max) {
                    max = price[j] - min;
                }
            }
        } if (price[i] < min) min = price[i];
            else continue; price[i] < min price[i] price i min min = price[i] min price[i] price i continue; for (j = i+1; j < n; j++) {
                if (price[j] - min > max) {
                    max = price[j] - min;
                }
            } j = i+1; j = i+1 j i+1 i 1 j < n j n j++ j++ j {
                if (price[j] - min > max) {
                    max = price[j] - min;
                }
            } {
                if (price[j] - min > max) {
                    max = price[j] - min;
                }
            } if (price[j] - min > max) {
                    max = price[j] - min;
                } price[j] - min > max price[j] - min price[j] price j min max {
                    max = price[j] - min;
                } max = price[j] - min max price[j] - min price[j] price j min System.out.println(max) System.out.println System.out System System.out max String[] args args
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] price = new int[n];
        int i, j;

        for (i = 0; i < n; i++) {
            price[i] = Integer.parseInt(br.readLine());
        }

        int max = price[1] - price[0];
        int min = price[0] + 1;

        for (i = 0; i < n-1; i++) {
            if (price[i] < min) min = price[i];
            else continue;

            for (j = i+1; j < n; j++) {
                if (price[j] - min > max) {
                    max = price[j] - min;
                }
            }
        }
        System.out.println(max);
    }
}