N = int(input()) K = int(input()) L = [] for n in range(N): L.append(int(input())) L = sorted(L) print(L[-1] - L[0])