N=int(input())
K=int(input())
D=[int(input()) for x in range(N)]
D.sort()
MX=D[-1]
MN=D[0]
print(MX-MN)