N = int(input()) K = int(input()) n = [] for i in range(N): keep = int(input()) n.append(keep) n.sort() print(n[len(n) - 1] - n[0])