
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int max = scn.nextInt();
		int min = max;
		for(int i=0;i<n-1;i++){
			int a = scn.nextInt();
			if(a > max){
				max = a;
			}
			if( a < min){
				min = a;
			}
		}

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