import math N = int(input()) K = int(input()) n = [int(input()) for i in range(K)] n_max = max(n) n_min = min(n) ans = math.ceil(n_max - n_min) print(ans)