import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int max = -2000000000;
    int min = stdIn.nextInt();
    for (int i = 1; i < n; i++) {
      int now = stdIn.nextInt();
      if (now - min > max) 
        max = now - min;
      if (now < min)
        min = now;
    }
    System.out.println(max);
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int max = -2000000000;
    int min = stdIn.nextInt();
    for (int i = 1; i < n; i++) {
      int now = stdIn.nextInt();
      if (now - min > max) 
        max = now - min;
      if (now < min)
        min = now;
    }
    System.out.println(max);
  }
} Main public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int max = -2000000000;
    int min = stdIn.nextInt();
    for (int i = 1; i < n; i++) {
      int now = stdIn.nextInt();
      if (now - min > max) 
        max = now - min;
      if (now < min)
        min = now;
    }
    System.out.println(max);
  } main {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int max = -2000000000;
    int min = stdIn.nextInt();
    for (int i = 1; i < n; i++) {
      int now = stdIn.nextInt();
      if (now - min > max) 
        max = now - min;
      if (now < min)
        min = now;
    }
    System.out.println(max);
  } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int n = stdIn.nextInt(); n stdIn.nextInt() stdIn.nextInt stdIn int max = -2000000000; max -2000000000 2000000000 int min = stdIn.nextInt(); min stdIn.nextInt() stdIn.nextInt stdIn for (int i = 1; i < n; i++) {
      int now = stdIn.nextInt();
      if (now - min > max) 
        max = now - min;
      if (now < min)
        min = now;
    } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
      int now = stdIn.nextInt();
      if (now - min > max) 
        max = now - min;
      if (now < min)
        min = now;
    } {
      int now = stdIn.nextInt();
      if (now - min > max) 
        max = now - min;
      if (now < min)
        min = now;
    } int now = stdIn.nextInt(); now stdIn.nextInt() stdIn.nextInt stdIn if (now - min > max) 
        max = now - min; now - min > max now - min now min max max = now - min max now - min now min if (now < min)
        min = now; now < min now min min = now min now 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 stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int max = -2000000000;
    int min = stdIn.nextInt();
    for (int i = 1; i < n; i++) {
      int now = stdIn.nextInt();
      if (now - min > max) 
        max = now - min;
      if (now < min)
        min = now;
    }
    System.out.println(max);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int max = -2000000000;
    int min = stdIn.nextInt();
    for (int i = 1; i < n; i++) {
      int now = stdIn.nextInt();
      if (now - min > max) 
        max = now - min;
      if (now < min)
        min = now;
    }
    System.out.println(max);
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int max = -2000000000;
    int min = stdIn.nextInt();
    for (int i = 1; i < n; i++) {
      int now = stdIn.nextInt();
      if (now - min > max) 
        max = now - min;
      if (now < min)
        min = now;
    }
    System.out.println(max);
  }
}