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