import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] s = new int[n];
		int max = 0;
		int min = 1001;

		for (int i=0; i<n; i++){
			s[i] = sc.nextInt();
			if (s[i] >= max){
				max = s[i];
			}
			if (s[i] <= min){
				min = s[i];
			}
		}

		System.out.println(max-min);

	}
}