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