N = int(input()) K = int(input()) num = [0] * N for i in range(N): num[i] = int(input()) num.sort() ans = num[-1] - num[0] print(ans)