import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int r0 = sc.nextInt();
    int r = sc.nextInt();
    int max = r - r0;
    int min = Math.min(r, r0);
    for(int i = 2; i < n; i++) {
      r = sc.nextInt();
      max = Math.max(max, r - min);
      min = Math.min(min, r);
    }
    System.out.println(max);
  }
}
 import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int r0 = sc.nextInt();
    int r = sc.nextInt();
    int max = r - r0;
    int min = Math.min(r, r0);
    for(int i = 2; i < n; i++) {
      r = sc.nextInt();
      max = Math.max(max, r - min);
      min = Math.min(min, r);
    }
    System.out.println(max);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int r0 = sc.nextInt();
    int r = sc.nextInt();
    int max = r - r0;
    int min = Math.min(r, r0);
    for(int i = 2; i < n; i++) {
      r = sc.nextInt();
      max = Math.max(max, r - min);
      min = Math.min(min, r);
    }
    System.out.println(max);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int r0 = sc.nextInt();
    int r = sc.nextInt();
    int max = r - r0;
    int min = Math.min(r, r0);
    for(int i = 2; i < n; i++) {
      r = sc.nextInt();
      max = Math.max(max, r - min);
      min = Math.min(min, r);
    }
    System.out.println(max);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int r0 = sc.nextInt(); r0 sc.nextInt() sc.nextInt sc int r = sc.nextInt(); r sc.nextInt() sc.nextInt sc int max = r - r0; max r - r0 r r0 int min = Math.min(r, r0); min Math.min(r, r0) Math.min Math r r0 for(int i = 2; i < n; i++) {
      r = sc.nextInt();
      max = Math.max(max, r - min);
      min = Math.min(min, r);
    } int i = 2; int i = 2; i 2 i < n i n i++ i++ i {
      r = sc.nextInt();
      max = Math.max(max, r - min);
      min = Math.min(min, r);
    } {
      r = sc.nextInt();
      max = Math.max(max, r - min);
      min = Math.min(min, r);
    } r = sc.nextInt() r sc.nextInt() sc.nextInt sc max = Math.max(max, r - min) max Math.max(max, r - min) Math.max Math max r - min r min min = Math.min(min, r) min Math.min(min, r) Math.min Math min r 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 n = sc.nextInt();
    int r0 = sc.nextInt();
    int r = sc.nextInt();
    int max = r - r0;
    int min = Math.min(r, r0);
    for(int i = 2; i < n; i++) {
      r = sc.nextInt();
      max = Math.max(max, r - min);
      min = Math.min(min, r);
    }
    System.out.println(max);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int r0 = sc.nextInt();
    int r = sc.nextInt();
    int max = r - r0;
    int min = Math.min(r, r0);
    for(int i = 2; i < n; i++) {
      r = sc.nextInt();
      max = Math.max(max, r - min);
      min = Math.min(min, r);
    }
    System.out.println(max);
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int r0 = sc.nextInt();
    int r = sc.nextInt();
    int max = r - r0;
    int min = Math.min(r, r0);
    for(int i = 2; i < n; i++) {
      r = sc.nextInt();
      max = Math.max(max, r - min);
      min = Math.min(min, r);
    }
    System.out.println(max);
  }
}

