import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
    	int N = scanner.nextInt();
		int diff = 0;
		
		//自動ソートしてくれるset
		Set<Integer> treeSet = new TreeSet<>();
    	
		for (int i = 0; i < N; i++) {
			treeSet.add(scanner.nextInt());
		}
		
		try {
			//treeSetをlistに格納
			//Integer[] list = new Integer[N];
			//treeSet.toArray(list);
			
			Integer[] list = treeSet.toArray(new Integer[N]);
			
			int min = list[0];
			int max = list[list.length - 1];
			
			//System.out.println("min : " + min);
			//System.out.println("max : " + max);
			
			diff = max - min;
			System.out.println(diff);
		
		} catch (NullPointerException e) {
			//System.err.println("エラー" + e.getMessage());
			System.out.println(diff);
		}
	}
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz