import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int count = Integer.parseInt(sc.nextLine());

        int[] rates = new int[count];
        for (int i = 0; i < count; i++) {
        	rates[i] = Integer.parseInt(sc.nextLine());
        }

        int min = rates[0];
        int max = rates[1] - rates[0];
        for (int i = 1; i < count; i++) {
        	max = Math.max(max, rates[i] - min);
        	min = Math.min(min, rates[i]);
        }

        System.out.println(max);
    }

} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int count = Integer.parseInt(sc.nextLine());

        int[] rates = new int[count];
        for (int i = 0; i < count; i++) {
        	rates[i] = Integer.parseInt(sc.nextLine());
        }

        int min = rates[0];
        int max = rates[1] - rates[0];
        for (int i = 1; i < count; i++) {
        	max = Math.max(max, rates[i] - min);
        	min = Math.min(min, rates[i]);
        }

        System.out.println(max);
    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int count = Integer.parseInt(sc.nextLine());

        int[] rates = new int[count];
        for (int i = 0; i < count; i++) {
        	rates[i] = Integer.parseInt(sc.nextLine());
        }

        int min = rates[0];
        int max = rates[1] - rates[0];
        for (int i = 1; i < count; i++) {
        	max = Math.max(max, rates[i] - min);
        	min = Math.min(min, rates[i]);
        }

        System.out.println(max);
    } main {
        Scanner sc = new Scanner(System.in);

        int count = Integer.parseInt(sc.nextLine());

        int[] rates = new int[count];
        for (int i = 0; i < count; i++) {
        	rates[i] = Integer.parseInt(sc.nextLine());
        }

        int min = rates[0];
        int max = rates[1] - rates[0];
        for (int i = 1; i < count; i++) {
        	max = Math.max(max, rates[i] - min);
        	min = Math.min(min, rates[i]);
        }

        System.out.println(max);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int count = Integer.parseInt(sc.nextLine()); count Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc int[] rates = new int[count]; rates new int[count] count for (int i = 0; i < count; i++) {
        	rates[i] = Integer.parseInt(sc.nextLine());
        } int i = 0; int i = 0; i 0 i < count i count i++ i++ i {
        	rates[i] = Integer.parseInt(sc.nextLine());
        } {
        	rates[i] = Integer.parseInt(sc.nextLine());
        } rates[i] = Integer.parseInt(sc.nextLine()) rates[i] rates i Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc int min = rates[0]; min rates[0] rates 0 int max = rates[1] - rates[0]; max rates[1] - rates[0] rates[1] rates 1 rates[0] rates 0 for (int i = 1; i < count; i++) {
        	max = Math.max(max, rates[i] - min);
        	min = Math.min(min, rates[i]);
        } int i = 1; int i = 1; i 1 i < count i count i++ i++ i {
        	max = Math.max(max, rates[i] - min);
        	min = Math.min(min, rates[i]);
        } {
        	max = Math.max(max, rates[i] - min);
        	min = Math.min(min, rates[i]);
        } max = Math.max(max, rates[i] - min) max Math.max(max, rates[i] - min) Math.max Math max rates[i] - min rates[i] rates i min min = Math.min(min, rates[i]) min Math.min(min, rates[i]) Math.min Math min rates[i] rates i System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int count = Integer.parseInt(sc.nextLine());

        int[] rates = new int[count];
        for (int i = 0; i < count; i++) {
        	rates[i] = Integer.parseInt(sc.nextLine());
        }

        int min = rates[0];
        int max = rates[1] - rates[0];
        for (int i = 1; i < count; i++) {
        	max = Math.max(max, rates[i] - min);
        	min = Math.min(min, rates[i]);
        }

        System.out.println(max);
    }

} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int count = Integer.parseInt(sc.nextLine());

        int[] rates = new int[count];
        for (int i = 0; i < count; i++) {
        	rates[i] = Integer.parseInt(sc.nextLine());
        }

        int min = rates[0];
        int max = rates[1] - rates[0];
        for (int i = 1; i < count; i++) {
        	max = Math.max(max, rates[i] - min);
        	min = Math.min(min, rates[i]);
        }

        System.out.println(max);
    }

} Main
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int count = Integer.parseInt(sc.nextLine());

        int[] rates = new int[count];
        for (int i = 0; i < count; i++) {
        	rates[i] = Integer.parseInt(sc.nextLine());
        }

        int min = rates[0];
        int max = rates[1] - rates[0];
        for (int i = 1; i < count; i++) {
        	max = Math.max(max, rates[i] - min);
        	min = Math.min(min, rates[i]);
        }

        System.out.println(max);
    }

}
