import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i< N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		Collections.sort(list, Collections.reverseOrder());
		int diff = list.get(0) - list.get(N - 1);
		System.out.println(diff);
	}

} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections 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 = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i< N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		Collections.sort(list, Collections.reverseOrder());
		int diff = list.get(0) - list.get(N - 1);
		System.out.println(diff);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i< N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		Collections.sort(list, Collections.reverseOrder());
		int diff = list.get(0) - list.get(N - 1);
		System.out.println(diff);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i< N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		Collections.sort(list, Collections.reverseOrder());
		int diff = list.get(0) - list.get(N - 1);
		System.out.println(diff);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc ArrayList<Integer> list = new ArrayList<>(); list new ArrayList<>() for(int i = 0; i< N; i++) {
			list.add(Integer.parseInt(sc.next()));
		} int i = 0; int i = 0; i 0 i< N i N i++ i++ i {
			list.add(Integer.parseInt(sc.next()));
		} {
			list.add(Integer.parseInt(sc.next()));
		} list.add(Integer.parseInt(sc.next())) list.add list Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sc.close() sc.close sc Collections.sort(list, Collections.reverseOrder()) Collections.sort Collections list Collections.reverseOrder() Collections.reverseOrder Collections int diff = list.get(0) - list.get(N - 1); diff list.get(0) - list.get(N - 1) list.get(0) list.get list 0 list.get(N - 1) list.get list N - 1 N 1 System.out.println(diff) System.out.println System.out System System.out diff String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i< N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		Collections.sort(list, Collections.reverseOrder());
		int diff = list.get(0) - list.get(N - 1);
		System.out.println(diff);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i< N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		Collections.sort(list, Collections.reverseOrder());
		int diff = list.get(0) - list.get(N - 1);
		System.out.println(diff);
	}

} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i< N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		Collections.sort(list, Collections.reverseOrder());
		int diff = list.get(0) - list.get(N - 1);
		System.out.println(diff);
	}

}