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