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> aArrayList = new ArrayList<>();

		for (int i=0; i<N; i++){
			aArrayList.add(Integer.parseInt(sc.next()));
		}

		Collections.sort(aArrayList);

		System.out.println(Math.abs(aArrayList.get(0) - aArrayList.get(aArrayList.size()-1)));
	}
} 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> aArrayList = new ArrayList<>();

		for (int i=0; i<N; i++){
			aArrayList.add(Integer.parseInt(sc.next()));
		}

		Collections.sort(aArrayList);

		System.out.println(Math.abs(aArrayList.get(0) - aArrayList.get(aArrayList.size()-1)));
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());

		ArrayList<Integer> aArrayList = new ArrayList<>();

		for (int i=0; i<N; i++){
			aArrayList.add(Integer.parseInt(sc.next()));
		}

		Collections.sort(aArrayList);

		System.out.println(Math.abs(aArrayList.get(0) - aArrayList.get(aArrayList.size()-1)));
	} main {
		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());

		ArrayList<Integer> aArrayList = new ArrayList<>();

		for (int i=0; i<N; i++){
			aArrayList.add(Integer.parseInt(sc.next()));
		}

		Collections.sort(aArrayList);

		System.out.println(Math.abs(aArrayList.get(0) - aArrayList.get(aArrayList.size()-1)));
	} 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> aArrayList = new ArrayList<>(); aArrayList new ArrayList<>() for (int i=0; i<N; i++){
			aArrayList.add(Integer.parseInt(sc.next()));
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			aArrayList.add(Integer.parseInt(sc.next()));
		} {
			aArrayList.add(Integer.parseInt(sc.next()));
		} aArrayList.add(Integer.parseInt(sc.next())) aArrayList.add aArrayList Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Collections.sort(aArrayList) Collections.sort Collections aArrayList System.out.println(Math.abs(aArrayList.get(0) - aArrayList.get(aArrayList.size()-1))) System.out.println System.out System System.out Math.abs(aArrayList.get(0) - aArrayList.get(aArrayList.size()-1)) Math.abs Math aArrayList.get(0) - aArrayList.get(aArrayList.size()-1) aArrayList.get(0) aArrayList.get aArrayList 0 aArrayList.get(aArrayList.size()-1) aArrayList.get aArrayList aArrayList.size()-1 aArrayList.size() aArrayList.size aArrayList 1 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> aArrayList = new ArrayList<>();

		for (int i=0; i<N; i++){
			aArrayList.add(Integer.parseInt(sc.next()));
		}

		Collections.sort(aArrayList);

		System.out.println(Math.abs(aArrayList.get(0) - aArrayList.get(aArrayList.size()-1)));
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());

		ArrayList<Integer> aArrayList = new ArrayList<>();

		for (int i=0; i<N; i++){
			aArrayList.add(Integer.parseInt(sc.next()));
		}

		Collections.sort(aArrayList);

		System.out.println(Math.abs(aArrayList.get(0) - aArrayList.get(aArrayList.size()-1)));
	}
} 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> aArrayList = new ArrayList<>();

		for (int i=0; i<N; i++){
			aArrayList.add(Integer.parseInt(sc.next()));
		}

		Collections.sort(aArrayList);

		System.out.println(Math.abs(aArrayList.get(0) - aArrayList.get(aArrayList.size()-1)));
	}
}
