import java.util.Scanner;

/**
 * Created by ??\??? on 2016/12/2.
 */
public class Main {
    static int run(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
            int T = Integer.parseInt(scan.nextLine());
            int maxv = -1000000000;
            int min = -1;
            int pointer = -1;
            for (int i = 1; i <= T; i++) {
                pointer = Integer.parseInt(scan.nextLine());
                if (i == 1) {
                    min = pointer;
                } else {
                    maxv = (maxv > pointer - min) ? maxv : (pointer-min);
                    min = (min > pointer) ? pointer : min;
                }
            }
            System.out.println(maxv);
        }
        return 0;
    }
    public static void main(String[] args) {
        run(args);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    static int run(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
            int T = Integer.parseInt(scan.nextLine());
            int maxv = -1000000000;
            int min = -1;
            int pointer = -1;
            for (int i = 1; i <= T; i++) {
                pointer = Integer.parseInt(scan.nextLine());
                if (i == 1) {
                    min = pointer;
                } else {
                    maxv = (maxv > pointer - min) ? maxv : (pointer-min);
                    min = (min > pointer) ? pointer : min;
                }
            }
            System.out.println(maxv);
        }
        return 0;
    }
    public static void main(String[] args) {
        run(args);
    }
} Main static int run(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
            int T = Integer.parseInt(scan.nextLine());
            int maxv = -1000000000;
            int min = -1;
            int pointer = -1;
            for (int i = 1; i <= T; i++) {
                pointer = Integer.parseInt(scan.nextLine());
                if (i == 1) {
                    min = pointer;
                } else {
                    maxv = (maxv > pointer - min) ? maxv : (pointer-min);
                    min = (min > pointer) ? pointer : min;
                }
            }
            System.out.println(maxv);
        }
        return 0;
    } run {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
            int T = Integer.parseInt(scan.nextLine());
            int maxv = -1000000000;
            int min = -1;
            int pointer = -1;
            for (int i = 1; i <= T; i++) {
                pointer = Integer.parseInt(scan.nextLine());
                if (i == 1) {
                    min = pointer;
                } else {
                    maxv = (maxv > pointer - min) ? maxv : (pointer-min);
                    min = (min > pointer) ? pointer : min;
                }
            }
            System.out.println(maxv);
        }
        return 0;
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while(scan.hasNext()) {
            int T = Integer.parseInt(scan.nextLine());
            int maxv = -1000000000;
            int min = -1;
            int pointer = -1;
            for (int i = 1; i <= T; i++) {
                pointer = Integer.parseInt(scan.nextLine());
                if (i == 1) {
                    min = pointer;
                } else {
                    maxv = (maxv > pointer - min) ? maxv : (pointer-min);
                    min = (min > pointer) ? pointer : min;
                }
            }
            System.out.println(maxv);
        } scan.hasNext() scan.hasNext scan {
            int T = Integer.parseInt(scan.nextLine());
            int maxv = -1000000000;
            int min = -1;
            int pointer = -1;
            for (int i = 1; i <= T; i++) {
                pointer = Integer.parseInt(scan.nextLine());
                if (i == 1) {
                    min = pointer;
                } else {
                    maxv = (maxv > pointer - min) ? maxv : (pointer-min);
                    min = (min > pointer) ? pointer : min;
                }
            }
            System.out.println(maxv);
        } int T = Integer.parseInt(scan.nextLine()); T Integer.parseInt(scan.nextLine()) Integer.parseInt Integer scan.nextLine() scan.nextLine scan int maxv = -1000000000; maxv -1000000000 1000000000 int min = -1; min -1 1 int pointer = -1; pointer -1 1 for (int i = 1; i <= T; i++) {
                pointer = Integer.parseInt(scan.nextLine());
                if (i == 1) {
                    min = pointer;
                } else {
                    maxv = (maxv > pointer - min) ? maxv : (pointer-min);
                    min = (min > pointer) ? pointer : min;
                }
            } int i = 1; int i = 1; i 1 i <= T i T i++ i++ i {
                pointer = Integer.parseInt(scan.nextLine());
                if (i == 1) {
                    min = pointer;
                } else {
                    maxv = (maxv > pointer - min) ? maxv : (pointer-min);
                    min = (min > pointer) ? pointer : min;
                }
            } {
                pointer = Integer.parseInt(scan.nextLine());
                if (i == 1) {
                    min = pointer;
                } else {
                    maxv = (maxv > pointer - min) ? maxv : (pointer-min);
                    min = (min > pointer) ? pointer : min;
                }
            } pointer = Integer.parseInt(scan.nextLine()) pointer Integer.parseInt(scan.nextLine()) Integer.parseInt Integer scan.nextLine() scan.nextLine scan if (i == 1) {
                    min = pointer;
                } else {
                    maxv = (maxv > pointer - min) ? maxv : (pointer-min);
                    min = (min > pointer) ? pointer : min;
                } i == 1 i 1 {
                    min = pointer;
                } min = pointer min pointer {
                    maxv = (maxv > pointer - min) ? maxv : (pointer-min);
                    min = (min > pointer) ? pointer : min;
                } maxv = (maxv > pointer - min) ? maxv : (pointer-min) maxv (maxv > pointer - min) ? maxv : (pointer-min) (maxv > pointer - min) maxv pointer - min pointer min maxv (pointer-min) pointer min min = (min > pointer) ? pointer : min min (min > pointer) ? pointer : min (min > pointer) min pointer pointer min System.out.println(maxv) System.out.println System.out System System.out maxv return 0; 0 String[] args args public static void main(String[] args) {
        run(args);
    } main {
        run(args);
    } run(args) run args String[] args args public class Main {
    static int run(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
            int T = Integer.parseInt(scan.nextLine());
            int maxv = -1000000000;
            int min = -1;
            int pointer = -1;
            for (int i = 1; i <= T; i++) {
                pointer = Integer.parseInt(scan.nextLine());
                if (i == 1) {
                    min = pointer;
                } else {
                    maxv = (maxv > pointer - min) ? maxv : (pointer-min);
                    min = (min > pointer) ? pointer : min;
                }
            }
            System.out.println(maxv);
        }
        return 0;
    }
    public static void main(String[] args) {
        run(args);
    }
} public class Main {
    static int run(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
            int T = Integer.parseInt(scan.nextLine());
            int maxv = -1000000000;
            int min = -1;
            int pointer = -1;
            for (int i = 1; i <= T; i++) {
                pointer = Integer.parseInt(scan.nextLine());
                if (i == 1) {
                    min = pointer;
                } else {
                    maxv = (maxv > pointer - min) ? maxv : (pointer-min);
                    min = (min > pointer) ? pointer : min;
                }
            }
            System.out.println(maxv);
        }
        return 0;
    }
    public static void main(String[] args) {
        run(args);
    }
} Main
import java.util.Scanner;

/**
 * Created by ??\??? on 2016/12/2.
 */
public class Main {
    static int run(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
            int T = Integer.parseInt(scan.nextLine());
            int maxv = -1000000000;
            int min = -1;
            int pointer = -1;
            for (int i = 1; i <= T; i++) {
                pointer = Integer.parseInt(scan.nextLine());
                if (i == 1) {
                    min = pointer;
                } else {
                    maxv = (maxv > pointer - min) ? maxv : (pointer-min);
                    min = (min > pointer) ? pointer : min;
                }
            }
            System.out.println(maxv);
        }
        return 0;
    }
    public static void main(String[] args) {
        run(args);
    }
}