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