lst = []
n = int(input())
m = int(input())
for i in range(n):
    s = int(input())
    lst.append(s)
lst = sorted(lst)
print(lst[-1]-lst[0])