import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] a = new int[n];
		a[0] = scanner.nextInt();
		int max = a[0], min = a[0];

		for (int i = 1; i < n; i++) {
			a[i] = scanner.nextInt();
			if(max < a[i]){
				max = a[i];
			}else if(min > a[i]){
				min = a[i];
			}
		}

		System.out.println(max-min);
	}
}