n = int(input()) k = int(input()) li = [0] * n for i in range(n): li[i] = int(input()) li.sort() print(li[-1] - li[0])