# No. 21 平均の差 N, K = [int(input()) for i in range(2)] n = [int(input()) for i in range(N)] print(max(n) - min(n))