n = int(input()) k = int(input()) nums = [int(input()) for _ in range(n)] max_num = max(nums) min_num = min(nums) print(max_num - min_num)