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