import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		TreeSet<Integer> ts = new TreeSet<>();
		int n = scan.nextInt();
		for (int i = 0; i < n; i++) {
			ts.add(scan.nextInt());
		}
		System.out.println(ts.last() - ts.first());
	}

}