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