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