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