i=input N,K=map(int,(i(),i())) D=sorted([int(i()) for x in range(N)]) print(D[-1]-D[0])