N = int(input()) K = int(input()) a = [int(input()) for i in range(N)] b=sorted(a) print(b[-1]-b[0])