N=int(input()) K=int(input()) n=[0]*N for i in range(N): n[i]=int(input()) print(max(n)-min(n))