N = int(input()) K = int(input()) n = [int(input()) for _ in range(N) ] l = min(n) h = max(n) print(h - l)