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