import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int ma = 0;
		int mi = 1000000007;

		for (int i = 0; i < n; i++) {
			ma = Math.max(a[i], ma);
			mi = Math.min(a[i], mi);
		}

		System.out.println(ma - mi);
	}

} 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();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int ma = 0;
		int mi = 1000000007;

		for (int i = 0; i < n; i++) {
			ma = Math.max(a[i], ma);
			mi = Math.min(a[i], mi);
		}

		System.out.println(ma - mi);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int ma = 0;
		int mi = 1000000007;

		for (int i = 0; i < n; i++) {
			ma = Math.max(a[i], ma);
			mi = Math.min(a[i], mi);
		}

		System.out.println(ma - mi);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int ma = 0;
		int mi = 1000000007;

		for (int i = 0; i < n; i++) {
			ma = Math.max(a[i], ma);
			mi = Math.min(a[i], mi);
		}

		System.out.println(ma - mi);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int a[] = new int[n]; a new int[n] n for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			a[i] = sc.nextInt();
		} {
			a[i] = sc.nextInt();
		} a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc int ma = 0; ma 0 int mi = 1000000007; mi 1000000007 for (int i = 0; i < n; i++) {
			ma = Math.max(a[i], ma);
			mi = Math.min(a[i], mi);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			ma = Math.max(a[i], ma);
			mi = Math.min(a[i], mi);
		} {
			ma = Math.max(a[i], ma);
			mi = Math.min(a[i], mi);
		} ma = Math.max(a[i], ma) ma Math.max(a[i], ma) Math.max Math a[i] a i ma mi = Math.min(a[i], mi) mi Math.min(a[i], mi) Math.min Math a[i] a i mi System.out.println(ma - mi) System.out.println System.out System System.out ma - mi ma mi String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int ma = 0;
		int mi = 1000000007;

		for (int i = 0; i < n; i++) {
			ma = Math.max(a[i], ma);
			mi = Math.min(a[i], mi);
		}

		System.out.println(ma - mi);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int ma = 0;
		int mi = 1000000007;

		for (int i = 0; i < n; i++) {
			ma = Math.max(a[i], ma);
			mi = Math.min(a[i], mi);
		}

		System.out.println(ma - mi);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int ma = 0;
		int mi = 1000000007;

		for (int i = 0; i < n; i++) {
			ma = Math.max(a[i], ma);
			mi = Math.min(a[i], mi);
		}

		System.out.println(ma - mi);
	}

}
