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