N = int(raw_input().strip()) K = int(raw_input().strip()) n = [] for i in range(N): n.append(int(raw_input().strip())) n = sorted(n) print n[-1] - n[0]