n = int(input()) k = int(input()) d = [] for _ in range(n): d.append(int(input())) x = max(d) - min(d) print(x)