n = input() N = int(n) k = input() l = [] for v in range(1, N+1): a = input() A = int(a) l.append(A) m = max(l) n = min(l) print(m - n)