N = int(input()) K = int(input()) n = int(input()) mx = mn = n for i in range(N-1): n = int(input()) mn = min(mn, n) mx = max(mx, n) print(mx - mn)