import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.nextLine());
    long[] as = new long[N];
    long[] dp = new long[N];
    String[] firstInput = sc.nextLine().split("[\\s]+");
    for(int i = 0; i < N; i++) {
      as[i] = Long.parseLong(firstInput[i]);
    }
    Arrays.sort(as);
    System.out.println(Math.abs(as[0] - as[N -1]));
  }
} import java.util.*; util.* java public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.nextLine());
    long[] as = new long[N];
    long[] dp = new long[N];
    String[] firstInput = sc.nextLine().split("[\\s]+");
    for(int i = 0; i < N; i++) {
      as[i] = Long.parseLong(firstInput[i]);
    }
    Arrays.sort(as);
    System.out.println(Math.abs(as[0] - as[N -1]));
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.nextLine());
    long[] as = new long[N];
    long[] dp = new long[N];
    String[] firstInput = sc.nextLine().split("[\\s]+");
    for(int i = 0; i < N; i++) {
      as[i] = Long.parseLong(firstInput[i]);
    }
    Arrays.sort(as);
    System.out.println(Math.abs(as[0] - as[N -1]));
  } main {
    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.nextLine());
    long[] as = new long[N];
    long[] dp = new long[N];
    String[] firstInput = sc.nextLine().split("[\\s]+");
    for(int i = 0; i < N; i++) {
      as[i] = Long.parseLong(firstInput[i]);
    }
    Arrays.sort(as);
    System.out.println(Math.abs(as[0] - as[N -1]));
  } 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 long[] as = new long[N]; as new long[N] N long[] dp = new long[N]; dp new long[N] N String[] firstInput = sc.nextLine().split("[\\s]+"); firstInput sc.nextLine().split("[\\s]+") sc.nextLine().split sc.nextLine() sc.nextLine sc "[\\s]+" for(int i = 0; i < N; i++) {
      as[i] = Long.parseLong(firstInput[i]);
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      as[i] = Long.parseLong(firstInput[i]);
    } {
      as[i] = Long.parseLong(firstInput[i]);
    } as[i] = Long.parseLong(firstInput[i]) as[i] as i Long.parseLong(firstInput[i]) Long.parseLong Long firstInput[i] firstInput i Arrays.sort(as) Arrays.sort Arrays as System.out.println(Math.abs(as[0] - as[N -1])) System.out.println System.out System System.out Math.abs(as[0] - as[N -1]) Math.abs Math as[0] - as[N -1] as[0] as 0 as[N -1] as N -1 N 1 String[] args args public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.nextLine());
    long[] as = new long[N];
    long[] dp = new long[N];
    String[] firstInput = sc.nextLine().split("[\\s]+");
    for(int i = 0; i < N; i++) {
      as[i] = Long.parseLong(firstInput[i]);
    }
    Arrays.sort(as);
    System.out.println(Math.abs(as[0] - as[N -1]));
  }
} public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.nextLine());
    long[] as = new long[N];
    long[] dp = new long[N];
    String[] firstInput = sc.nextLine().split("[\\s]+");
    for(int i = 0; i < N; i++) {
      as[i] = Long.parseLong(firstInput[i]);
    }
    Arrays.sort(as);
    System.out.println(Math.abs(as[0] - as[N -1]));
  }
} Main
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.nextLine());
    long[] as = new long[N];
    long[] dp = new long[N];
    String[] firstInput = sc.nextLine().split("[\\s]+");
    for(int i = 0; i < N; i++) {
      as[i] = Long.parseLong(firstInput[i]);
    }
    Arrays.sort(as);
    System.out.println(Math.abs(as[0] - as[N -1]));
  }
}
