import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for(int i = 0; i < N; i++)
		{
			list.add(sc.nextInt());
		}
		int max = list.stream().max((a, b) -> a.compareTo(b)).get();
		int min = list.stream().min((a, b) -> a.compareTo(b)).get();
		System.out.println(max - min);
	}

}
