from math import ceil N = int(input()) K = int(input()) nums = [] for i in range(N): nums.append(int(input())) print(ceil(max(nums) - min(nums)))