N = int(input()) K = int(input()) n = list(int(input()) for _ in range(N)) print(max(n) - min(n))