n = int(input()) m = int(input()) s = [] for j in range(n): s.append(int(input())) print(max(s)-min(s))