import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String m = sc.nextLine();
    String[] mm = m.split(" ");
    int[] o = new int[n];
    for (int i = 0; i < n; i++) {
      o[i] = Integer.parseInt(mm[i]);
    }
    Arrays.sort(o);
    System.out.println(o[n - 1] - o[0]);
  }
} import java.util.*; util.* java class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String m = sc.nextLine();
    String[] mm = m.split(" ");
    int[] o = new int[n];
    for (int i = 0; i < n; i++) {
      o[i] = Integer.parseInt(mm[i]);
    }
    Arrays.sort(o);
    System.out.println(o[n - 1] - o[0]);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String m = sc.nextLine();
    String[] mm = m.split(" ");
    int[] o = new int[n];
    for (int i = 0; i < n; i++) {
      o[i] = Integer.parseInt(mm[i]);
    }
    Arrays.sort(o);
    System.out.println(o[n - 1] - o[0]);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String m = sc.nextLine();
    String[] mm = m.split(" ");
    int[] o = new int[n];
    for (int i = 0; i < n; i++) {
      o[i] = Integer.parseInt(mm[i]);
    }
    Arrays.sort(o);
    System.out.println(o[n - 1] - o[0]);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.nextLine()); n Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc String m = sc.nextLine(); m sc.nextLine() sc.nextLine sc String[] mm = m.split(" "); mm m.split(" ") m.split m " " int[] o = new int[n]; o new int[n] n for (int i = 0; i < n; i++) {
      o[i] = Integer.parseInt(mm[i]);
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      o[i] = Integer.parseInt(mm[i]);
    } {
      o[i] = Integer.parseInt(mm[i]);
    } o[i] = Integer.parseInt(mm[i]) o[i] o i Integer.parseInt(mm[i]) Integer.parseInt Integer mm[i] mm i Arrays.sort(o) Arrays.sort Arrays o System.out.println(o[n - 1] - o[0]) System.out.println System.out System System.out o[n - 1] - o[0] o[n - 1] o n - 1 n 1 o[0] o 0 String[] args args
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String m = sc.nextLine();
    String[] mm = m.split(" ");
    int[] o = new int[n];
    for (int i = 0; i < n; i++) {
      o[i] = Integer.parseInt(mm[i]);
    }
    Arrays.sort(o);
    System.out.println(o[n - 1] - o[0]);
  }
}