n, k = io.read("*n", "*n") min = io.read("*n") max = min for i = 2, n do a = io.read("*n") min, max = math.min(a, min), math.max(a, max) end print(max - min)