import java.util.*;
import java.io.*;
import java.lang.*;

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

        int n = sc.nextInt();
        ArrayList<Integer> arr = new ArrayList<>();
        for (int i = 0; i<n; i++){
            int a = sc.nextInt();
            arr.add(a);
        }
        Collections.sort(arr);
        System.out.println(arr.get(n-1)-arr.get(0));

    }
} import java.util.*; util.* java import java.io.*; io.* java import java.lang.*; lang.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        ArrayList<Integer> arr = new ArrayList<>();
        for (int i = 0; i<n; i++){
            int a = sc.nextInt();
            arr.add(a);
        }
        Collections.sort(arr);
        System.out.println(arr.get(n-1)-arr.get(0));

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

        int n = sc.nextInt();
        ArrayList<Integer> arr = new ArrayList<>();
        for (int i = 0; i<n; i++){
            int a = sc.nextInt();
            arr.add(a);
        }
        Collections.sort(arr);
        System.out.println(arr.get(n-1)-arr.get(0));

    } main {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        ArrayList<Integer> arr = new ArrayList<>();
        for (int i = 0; i<n; i++){
            int a = sc.nextInt();
            arr.add(a);
        }
        Collections.sort(arr);
        System.out.println(arr.get(n-1)-arr.get(0));

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc ArrayList<Integer> arr = new ArrayList<>(); arr new ArrayList<>() for (int i = 0; i<n; i++){
            int a = sc.nextInt();
            arr.add(a);
        } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
            int a = sc.nextInt();
            arr.add(a);
        } {
            int a = sc.nextInt();
            arr.add(a);
        } int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc arr.add(a) arr.add arr a Collections.sort(arr) Collections.sort Collections arr System.out.println(arr.get(n-1)-arr.get(0)) System.out.println System.out System System.out arr.get(n-1)-arr.get(0) arr.get(n-1) arr.get arr n-1 n 1 arr.get(0) arr.get arr 0 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        ArrayList<Integer> arr = new ArrayList<>();
        for (int i = 0; i<n; i++){
            int a = sc.nextInt();
            arr.add(a);
        }
        Collections.sort(arr);
        System.out.println(arr.get(n-1)-arr.get(0));

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

        int n = sc.nextInt();
        ArrayList<Integer> arr = new ArrayList<>();
        for (int i = 0; i<n; i++){
            int a = sc.nextInt();
            arr.add(a);
        }
        Collections.sort(arr);
        System.out.println(arr.get(n-1)-arr.get(0));

    }
} Main
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int n = sc.nextInt();
        ArrayList<Integer> arr = new ArrayList<>();
        for (int i = 0; i<n; i++){
            int a = sc.nextInt();
            arr.add(a);
        }
        Collections.sort(arr);
        System.out.println(arr.get(n-1)-arr.get(0));

    }
}