import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    List<Integer> arr = new ArrayList<>();
    int min = 0;
    int max = 0;
    for(int i = 0; i < n; i++) {
      arr.add(sc.nextInt());
      if(i == 0) {
        min = arr.get(0);
        continue;
      } else {
        if(min > arr.get(i - 1)) {
          min = arr.get(i - 1);
        }
        if(i == 1) {
          max = arr.get(1) - arr.get(0);
        } else if(max < arr.get(i) - min) {
          max = arr.get(i) - min;
        }
      }
    }
    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();
    List<Integer> arr = new ArrayList<>();
    int min = 0;
    int max = 0;
    for(int i = 0; i < n; i++) {
      arr.add(sc.nextInt());
      if(i == 0) {
        min = arr.get(0);
        continue;
      } else {
        if(min > arr.get(i - 1)) {
          min = arr.get(i - 1);
        }
        if(i == 1) {
          max = arr.get(1) - arr.get(0);
        } else if(max < arr.get(i) - min) {
          max = arr.get(i) - min;
        }
      }
    }
    System.out.println(max);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    List<Integer> arr = new ArrayList<>();
    int min = 0;
    int max = 0;
    for(int i = 0; i < n; i++) {
      arr.add(sc.nextInt());
      if(i == 0) {
        min = arr.get(0);
        continue;
      } else {
        if(min > arr.get(i - 1)) {
          min = arr.get(i - 1);
        }
        if(i == 1) {
          max = arr.get(1) - arr.get(0);
        } else if(max < arr.get(i) - min) {
          max = arr.get(i) - min;
        }
      }
    }
    System.out.println(max);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    List<Integer> arr = new ArrayList<>();
    int min = 0;
    int max = 0;
    for(int i = 0; i < n; i++) {
      arr.add(sc.nextInt());
      if(i == 0) {
        min = arr.get(0);
        continue;
      } else {
        if(min > arr.get(i - 1)) {
          min = arr.get(i - 1);
        }
        if(i == 1) {
          max = arr.get(1) - arr.get(0);
        } else if(max < arr.get(i) - min) {
          max = arr.get(i) - min;
        }
      }
    }
    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 List<Integer> arr = new ArrayList<>(); arr new ArrayList<>() int min = 0; min 0 int max = 0; max 0 for(int i = 0; i < n; i++) {
      arr.add(sc.nextInt());
      if(i == 0) {
        min = arr.get(0);
        continue;
      } else {
        if(min > arr.get(i - 1)) {
          min = arr.get(i - 1);
        }
        if(i == 1) {
          max = arr.get(1) - arr.get(0);
        } else if(max < arr.get(i) - min) {
          max = arr.get(i) - min;
        }
      }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      arr.add(sc.nextInt());
      if(i == 0) {
        min = arr.get(0);
        continue;
      } else {
        if(min > arr.get(i - 1)) {
          min = arr.get(i - 1);
        }
        if(i == 1) {
          max = arr.get(1) - arr.get(0);
        } else if(max < arr.get(i) - min) {
          max = arr.get(i) - min;
        }
      }
    } {
      arr.add(sc.nextInt());
      if(i == 0) {
        min = arr.get(0);
        continue;
      } else {
        if(min > arr.get(i - 1)) {
          min = arr.get(i - 1);
        }
        if(i == 1) {
          max = arr.get(1) - arr.get(0);
        } else if(max < arr.get(i) - min) {
          max = arr.get(i) - min;
        }
      }
    } arr.add(sc.nextInt()) arr.add arr sc.nextInt() sc.nextInt sc if(i == 0) {
        min = arr.get(0);
        continue;
      } else {
        if(min > arr.get(i - 1)) {
          min = arr.get(i - 1);
        }
        if(i == 1) {
          max = arr.get(1) - arr.get(0);
        } else if(max < arr.get(i) - min) {
          max = arr.get(i) - min;
        }
      } i == 0 i 0 {
        min = arr.get(0);
        continue;
      } min = arr.get(0) min arr.get(0) arr.get arr 0 continue; {
        if(min > arr.get(i - 1)) {
          min = arr.get(i - 1);
        }
        if(i == 1) {
          max = arr.get(1) - arr.get(0);
        } else if(max < arr.get(i) - min) {
          max = arr.get(i) - min;
        }
      } if(min > arr.get(i - 1)) {
          min = arr.get(i - 1);
        } min > arr.get(i - 1) min arr.get(i - 1) arr.get arr i - 1 i 1 {
          min = arr.get(i - 1);
        } min = arr.get(i - 1) min arr.get(i - 1) arr.get arr i - 1 i 1 if(i == 1) {
          max = arr.get(1) - arr.get(0);
        } else if(max < arr.get(i) - min) {
          max = arr.get(i) - min;
        } i == 1 i 1 {
          max = arr.get(1) - arr.get(0);
        } max = arr.get(1) - arr.get(0) max arr.get(1) - arr.get(0) arr.get(1) arr.get arr 1 arr.get(0) arr.get arr 0 if(max < arr.get(i) - min) {
          max = arr.get(i) - min;
        } max < arr.get(i) - min max arr.get(i) - min arr.get(i) arr.get arr i min {
          max = arr.get(i) - min;
        } max = arr.get(i) - min max arr.get(i) - min arr.get(i) arr.get arr i min 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();
    List<Integer> arr = new ArrayList<>();
    int min = 0;
    int max = 0;
    for(int i = 0; i < n; i++) {
      arr.add(sc.nextInt());
      if(i == 0) {
        min = arr.get(0);
        continue;
      } else {
        if(min > arr.get(i - 1)) {
          min = arr.get(i - 1);
        }
        if(i == 1) {
          max = arr.get(1) - arr.get(0);
        } else if(max < arr.get(i) - min) {
          max = arr.get(i) - min;
        }
      }
    }
    System.out.println(max);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    List<Integer> arr = new ArrayList<>();
    int min = 0;
    int max = 0;
    for(int i = 0; i < n; i++) {
      arr.add(sc.nextInt());
      if(i == 0) {
        min = arr.get(0);
        continue;
      } else {
        if(min > arr.get(i - 1)) {
          min = arr.get(i - 1);
        }
        if(i == 1) {
          max = arr.get(1) - arr.get(0);
        } else if(max < arr.get(i) - min) {
          max = arr.get(i) - min;
        }
      }
    }
    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();
    List<Integer> arr = new ArrayList<>();
    int min = 0;
    int max = 0;
    for(int i = 0; i < n; i++) {
      arr.add(sc.nextInt());
      if(i == 0) {
        min = arr.get(0);
        continue;
      } else {
        if(min > arr.get(i - 1)) {
          min = arr.get(i - 1);
        }
        if(i == 1) {
          max = arr.get(1) - arr.get(0);
        } else if(max < arr.get(i) - min) {
          max = arr.get(i) - min;
        }
      }
    }
    System.out.println(max);
  }
}

