N = int(input()) K = int(input()) n = sorted([int(input()) for _ in range(N)]) print(n[-1] - n[0])