rn = int(input()) k = int(input()) n = [] for i in range(rn): n.append = int(input()) print(max(n)-min(n))