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