N = int(input()) K = int(input()) numbers = [] for _ in range(N): numbers.append(int(input())) print(max(numbers) - min(numbers))