import java.util.*;

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

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

         int n = sc.nextInt();
         ArrayList<Integer> list = new ArrayList<>();
         for(int i = 0; i < n; i++) {
             list.add(sc.nextInt());
         }
              
        Integer max = list.stream().max(Comparator.naturalOrder()).get();;
        Integer min = list.stream().min(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();
         ArrayList<Integer> list = new ArrayList<>();
         for(int i = 0; i < n; i++) {
             list.add(sc.nextInt());
         }
              
        Integer max = list.stream().max(Comparator.naturalOrder()).get();;
        Integer min = list.stream().min(Comparator.naturalOrder()).get();;
        System.out.println(max - min);
    } main {
         Scanner sc = new Scanner(System.in);

         int n = sc.nextInt();
         ArrayList<Integer> list = new ArrayList<>();
         for(int i = 0; i < n; i++) {
             list.add(sc.nextInt());
         }
              
        Integer max = list.stream().max(Comparator.naturalOrder()).get();;
        Integer min = list.stream().min(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 ArrayList<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(sc.nextInt()) list.add list sc.nextInt() sc.nextInt sc Integer 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 Integer 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 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();
         ArrayList<Integer> list = new ArrayList<>();
         for(int i = 0; i < n; i++) {
             list.add(sc.nextInt());
         }
              
        Integer max = list.stream().max(Comparator.naturalOrder()).get();;
        Integer min = list.stream().min(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();
         ArrayList<Integer> list = new ArrayList<>();
         for(int i = 0; i < n; i++) {
             list.add(sc.nextInt());
         }
              
        Integer max = list.stream().max(Comparator.naturalOrder()).get();;
        Integer min = list.stream().min(Comparator.naturalOrder()).get();;
        System.out.println(max - min);
    } 
} Main
import java.util.*;

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

         int n = sc.nextInt();
         ArrayList<Integer> list = new ArrayList<>();
         for(int i = 0; i < n; i++) {
             list.add(sc.nextInt());
         }
              
        Integer max = list.stream().max(Comparator.naturalOrder()).get();;
        Integer min = list.stream().min(Comparator.naturalOrder()).get();;
        System.out.println(max - min);
    } 
}