import java.util.*;

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

		String line = sc.nextLine();
		int count = Integer.parseInt(line);

		List<Integer> list = new ArrayList<>();
		String[] array = sc.nextLine().split(" ");
		for (int i = 0; i < count; i++) {
			list.add(Integer.parseInt(array[i]));
		}
		int max = list.stream().max(Comparator.naturalOrder()).get();
		int 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);

		String line = sc.nextLine();
		int count = Integer.parseInt(line);

		List<Integer> list = new ArrayList<>();
		String[] array = sc.nextLine().split(" ");
		for (int i = 0; i < count; i++) {
			list.add(Integer.parseInt(array[i]));
		}
		int max = list.stream().max(Comparator.naturalOrder()).get();
		int 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);

		String line = sc.nextLine();
		int count = Integer.parseInt(line);

		List<Integer> list = new ArrayList<>();
		String[] array = sc.nextLine().split(" ");
		for (int i = 0; i < count; i++) {
			list.add(Integer.parseInt(array[i]));
		}
		int max = list.stream().max(Comparator.naturalOrder()).get();
		int min = list.stream().min(Comparator.naturalOrder()).get();
	
		System.out.println(max - min);
	} main {
		Scanner sc = new Scanner(System.in);

		String line = sc.nextLine();
		int count = Integer.parseInt(line);

		List<Integer> list = new ArrayList<>();
		String[] array = sc.nextLine().split(" ");
		for (int i = 0; i < count; i++) {
			list.add(Integer.parseInt(array[i]));
		}
		int max = list.stream().max(Comparator.naturalOrder()).get();
		int min = list.stream().min(Comparator.naturalOrder()).get();
	
		System.out.println(max - min);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc int count = Integer.parseInt(line); count Integer.parseInt(line) Integer.parseInt Integer line List<Integer> list = new ArrayList<>(); list new ArrayList<>() String[] array = sc.nextLine().split(" "); array sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " for (int i = 0; i < count; i++) {
			list.add(Integer.parseInt(array[i]));
		} int i = 0; int i = 0; i 0 i < count i count i++ i++ i {
			list.add(Integer.parseInt(array[i]));
		} {
			list.add(Integer.parseInt(array[i]));
		} list.add(Integer.parseInt(array[i])) list.add list Integer.parseInt(array[i]) Integer.parseInt Integer array[i] array i 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 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 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);

		String line = sc.nextLine();
		int count = Integer.parseInt(line);

		List<Integer> list = new ArrayList<>();
		String[] array = sc.nextLine().split(" ");
		for (int i = 0; i < count; i++) {
			list.add(Integer.parseInt(array[i]));
		}
		int max = list.stream().max(Comparator.naturalOrder()).get();
		int 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);

		String line = sc.nextLine();
		int count = Integer.parseInt(line);

		List<Integer> list = new ArrayList<>();
		String[] array = sc.nextLine().split(" ");
		for (int i = 0; i < count; i++) {
			list.add(Integer.parseInt(array[i]));
		}
		int max = list.stream().max(Comparator.naturalOrder()).get();
		int 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);

		String line = sc.nextLine();
		int count = Integer.parseInt(line);

		List<Integer> list = new ArrayList<>();
		String[] array = sc.nextLine().split(" ");
		for (int i = 0; i < count; i++) {
			list.add(Integer.parseInt(array[i]));
		}
		int max = list.stream().max(Comparator.naturalOrder()).get();
		int min = list.stream().min(Comparator.naturalOrder()).get();
	
		System.out.println(max - min);
	}
}
