N = int(input()) K = int(input()) data = [] for i in range(N): data.append(int(input())) print(max(data)-min(data))