n = int(input()) k = int(input()) num_lst = [ int(input()) for i in range(n)] num_lst.sort() print(num_lst[-1]-num_lst[0])