import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long min = sc.nextInt();
		long max = min;
		for(int i = 0; i < N-1; i++) {
			long A = sc.nextInt();
			min = Math.min(min,A);
			max = Math.max(max, A);
		}
		System.out.println(max-min);
	}
} 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();
		long min = sc.nextInt();
		long max = min;
		for(int i = 0; i < N-1; i++) {
			long A = sc.nextInt();
			min = Math.min(min,A);
			max = Math.max(max, A);
		}
		System.out.println(max-min);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long min = sc.nextInt();
		long max = min;
		for(int i = 0; i < N-1; i++) {
			long A = sc.nextInt();
			min = Math.min(min,A);
			max = Math.max(max, A);
		}
		System.out.println(max-min);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long min = sc.nextInt();
		long max = min;
		for(int i = 0; i < N-1; i++) {
			long A = sc.nextInt();
			min = Math.min(min,A);
			max = Math.max(max, A);
		}
		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 long min = sc.nextInt(); min sc.nextInt() sc.nextInt sc long max = min; max min for(int i = 0; i < N-1; i++) {
			long A = sc.nextInt();
			min = Math.min(min,A);
			max = Math.max(max, A);
		} int i = 0; int i = 0; i 0 i < N-1 i N-1 N 1 i++ i++ i {
			long A = sc.nextInt();
			min = Math.min(min,A);
			max = Math.max(max, A);
		} {
			long A = sc.nextInt();
			min = Math.min(min,A);
			max = Math.max(max, A);
		} long A = sc.nextInt(); A sc.nextInt() sc.nextInt sc min = Math.min(min,A) min Math.min(min,A) Math.min Math min A max = Math.max(max, A) max Math.max(max, A) Math.max Math max A 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();
		long min = sc.nextInt();
		long max = min;
		for(int i = 0; i < N-1; i++) {
			long A = sc.nextInt();
			min = Math.min(min,A);
			max = Math.max(max, A);
		}
		System.out.println(max-min);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long min = sc.nextInt();
		long max = min;
		for(int i = 0; i < N-1; i++) {
			long A = sc.nextInt();
			min = Math.min(min,A);
			max = Math.max(max, A);
		}
		System.out.println(max-min);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long min = sc.nextInt();
		long max = min;
		for(int i = 0; i < N-1; i++) {
			long A = sc.nextInt();
			min = Math.min(min,A);
			max = Math.max(max, A);
		}
		System.out.println(max-min);
	}
}
