N = int(input())
K = int(input())
lsn = [int(input()) for i in range(N)]
print(max(lsn)-min(lsn))