import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

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

        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) list.add(sc.nextInt());

        int min = list.stream().min(Comparator.naturalOrder()).get();
        int max = list.stream().max(Comparator.naturalOrder()).get();
        System.out.println(max-min);
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Comparator; Comparator java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) list.add(sc.nextInt());

        int min = list.stream().min(Comparator.naturalOrder()).get();
        int max = list.stream().max(Comparator.naturalOrder()).get();
        System.out.println(max-min);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) list.add(sc.nextInt());

        int min = list.stream().min(Comparator.naturalOrder()).get();
        int max = list.stream().max(Comparator.naturalOrder()).get();
        System.out.println(max-min);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) list.add(sc.nextInt());

        int min = list.stream().min(Comparator.naturalOrder()).get();
        int max = list.stream().max(Comparator.naturalOrder()).get();
        System.out.println(max-min);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc List<Integer> list = new ArrayList<>(); list new ArrayList<>() for (int i = 0; i < n; i++) list.add(sc.nextInt()); int i = 0; int i = 0; i 0 i < n i n i++ i++ i list.add(sc.nextInt()); list.add(sc.nextInt()) list.add list sc.nextInt() sc.nextInt sc int min = list.stream().min(Comparator.naturalOrder()).get(); min list.stream().min(Comparator.naturalOrder()).get() list.stream().min(Comparator.naturalOrder()).get list.stream().min(Comparator.naturalOrder()) list.stream().min list.stream() list.stream list Comparator.naturalOrder() Comparator.naturalOrder Comparator int max = list.stream().max(Comparator.naturalOrder()).get(); max list.stream().max(Comparator.naturalOrder()).get() list.stream().max(Comparator.naturalOrder()).get list.stream().max(Comparator.naturalOrder()) list.stream().max list.stream() list.stream list Comparator.naturalOrder() Comparator.naturalOrder Comparator System.out.println(max-min) System.out.println System.out System System.out max-min max min String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) list.add(sc.nextInt());

        int min = list.stream().min(Comparator.naturalOrder()).get();
        int max = list.stream().max(Comparator.naturalOrder()).get();
        System.out.println(max-min);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) list.add(sc.nextInt());

        int min = list.stream().min(Comparator.naturalOrder()).get();
        int max = list.stream().max(Comparator.naturalOrder()).get();
        System.out.println(max-min);
    }
} Main
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

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

        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) list.add(sc.nextInt());

        int min = list.stream().min(Comparator.naturalOrder()).get();
        int max = list.stream().max(Comparator.naturalOrder()).get();
        System.out.println(max-min);
    }
}