N = int(input()) K = int(input()) nums = [int(input()) for i in range(N)] print(max(nums) - min(nums))