n=int(input()) k=int(input()) a=[int(input()) for i in range(n)] a.sort() print(a[-1]-a[0])