N = int(input()) K = int(input()) n_list = [] for i in range(N): n_list.append(int(input())) print(max(n_list)-min(n_list))