N = int(input()) K = int(input()) s = set() for _ in range(N): s.add(int(input())) print(max(s)-min(s))