n=int(input()) k=int(input()) a=[int(input()) for _ in range(n)] print(max(a)-min(a))