n = int(input()) k = int(input()) mn = 10**5 mx = -1 for i in range(n): n = int(input()) if mn > n: mn = n if mx < n: mx = n print(mx - mn)