N = int(input())
K = int(input())
nums = [int(input()) for _ in range(N)]

nums.sort()
print(nums[-1] - nums[0])