N = int(input()) K = int(input()) M = 0 m = 10000 for i in range(N): x = int(input()) M = max(M, x) m = min(m, x) print(M - m)