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