import math
N = int(input())
K = int(input())
n = []
for i in range(N):
    n.append(int(input()))

n.sort()
print(math.ceil(n[-1] - n[0]))