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