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