import java.util.*;
class Main{
  public static void main(String args[]){

    int max = -1000000000;
    int rt;
    int min;

    Scanner sc = new Scanner(System.in);
    // input
    int n = sc.nextInt();
    //first
    min = sc.nextInt();
    //Comparison
    for(int i = 1; i<n; i++){
      rt = sc.nextInt();
      if(rt-min>max)max = rt-min;
      if(min>rt)min = rt;

    }
    System.out.println(max);
  }
} import java.util.*; util.* java class Main{
  public static void main(String args[]){

    int max = -1000000000;
    int rt;
    int min;

    Scanner sc = new Scanner(System.in);
    // input
    int n = sc.nextInt();
    //first
    min = sc.nextInt();
    //Comparison
    for(int i = 1; i<n; i++){
      rt = sc.nextInt();
      if(rt-min>max)max = rt-min;
      if(min>rt)min = rt;

    }
    System.out.println(max);
  }
} Main public static void main(String args[]){

    int max = -1000000000;
    int rt;
    int min;

    Scanner sc = new Scanner(System.in);
    // input
    int n = sc.nextInt();
    //first
    min = sc.nextInt();
    //Comparison
    for(int i = 1; i<n; i++){
      rt = sc.nextInt();
      if(rt-min>max)max = rt-min;
      if(min>rt)min = rt;

    }
    System.out.println(max);
  } main {

    int max = -1000000000;
    int rt;
    int min;

    Scanner sc = new Scanner(System.in);
    // input
    int n = sc.nextInt();
    //first
    min = sc.nextInt();
    //Comparison
    for(int i = 1; i<n; i++){
      rt = sc.nextInt();
      if(rt-min>max)max = rt-min;
      if(min>rt)min = rt;

    }
    System.out.println(max);
  } int max = -1000000000; max -1000000000 1000000000 int rt; rt int min; min Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc min = sc.nextInt() min sc.nextInt() sc.nextInt sc for(int i = 1; i<n; i++){
      rt = sc.nextInt();
      if(rt-min>max)max = rt-min;
      if(min>rt)min = rt;

    } int i = 1; int i = 1; i 1 i<n i n i++ i++ i {
      rt = sc.nextInt();
      if(rt-min>max)max = rt-min;
      if(min>rt)min = rt;

    } {
      rt = sc.nextInt();
      if(rt-min>max)max = rt-min;
      if(min>rt)min = rt;

    } rt = sc.nextInt() rt sc.nextInt() sc.nextInt sc if(rt-min>max)max = rt-min; rt-min>max rt-min rt min max max = rt-min max rt-min rt min if(min>rt)min = rt; min>rt min rt min = rt min rt System.out.println(max) System.out.println System.out System System.out max String args[] args
import java.util.*;
class Main{
  public static void main(String args[]){

    int max = -1000000000;
    int rt;
    int min;

    Scanner sc = new Scanner(System.in);
    // input
    int n = sc.nextInt();
    //first
    min = sc.nextInt();
    //Comparison
    for(int i = 1; i<n; i++){
      rt = sc.nextInt();
      if(rt-min>max)max = rt-min;
      if(min>rt)min = rt;

    }
    System.out.println(max);
  }
}
