N = int(input()) K = int(input()) nums = [int(input()) for _ in range(N)] nums.sort() ans = nums[-1] - nums[0] print(ans)