import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] line = scanner.nextLine().split(" ", n);

        long[] nums = new long[n];
        for (int i = 0; i < n; i++) {
            nums[i] = Long.parseLong(line[i]);
        }
        Arrays.sort(nums);

        System.out.println(nums[n - 1] - nums[0]);
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] line = scanner.nextLine().split(" ", n);

        long[] nums = new long[n];
        for (int i = 0; i < n; i++) {
            nums[i] = Long.parseLong(line[i]);
        }
        Arrays.sort(nums);

        System.out.println(nums[n - 1] - nums[0]);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] line = scanner.nextLine().split(" ", n);

        long[] nums = new long[n];
        for (int i = 0; i < n; i++) {
            nums[i] = Long.parseLong(line[i]);
        }
        Arrays.sort(nums);

        System.out.println(nums[n - 1] - nums[0]);
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] line = scanner.nextLine().split(" ", n);

        long[] nums = new long[n];
        for (int i = 0; i < n; i++) {
            nums[i] = Long.parseLong(line[i]);
        }
        Arrays.sort(nums);

        System.out.println(nums[n - 1] - nums[0]);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = Integer.parseInt(scanner.nextLine()); n Integer.parseInt(scanner.nextLine()) Integer.parseInt Integer scanner.nextLine() scanner.nextLine scanner String[] line = scanner.nextLine().split(" ", n); line scanner.nextLine().split(" ", n) scanner.nextLine().split scanner.nextLine() scanner.nextLine scanner " " n long[] nums = new long[n]; nums new long[n] n for (int i = 0; i < n; i++) {
            nums[i] = Long.parseLong(line[i]);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            nums[i] = Long.parseLong(line[i]);
        } {
            nums[i] = Long.parseLong(line[i]);
        } nums[i] = Long.parseLong(line[i]) nums[i] nums i Long.parseLong(line[i]) Long.parseLong Long line[i] line i Arrays.sort(nums) Arrays.sort Arrays nums System.out.println(nums[n - 1] - nums[0]) System.out.println System.out System System.out nums[n - 1] - nums[0] nums[n - 1] nums n - 1 n 1 nums[0] nums 0 String[] args args
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] line = scanner.nextLine().split(" ", n);

        long[] nums = new long[n];
        for (int i = 0; i < n; i++) {
            nums[i] = Long.parseLong(line[i]);
        }
        Arrays.sort(nums);

        System.out.println(nums[n - 1] - nums[0]);
    }
}
