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