import math n=int(input()) k=int(input()) l=[int(input()) for i in range(n)] l.sort() a=l[-1]-l[0] print(math.ceil(a))