N = int(input()) K = int(input()) X = [int(input()) for _ in range(N)] print(max(X) - min(X))