local N = tonumber(io.read())
local A = {}
for n in io.read():gmatch('%d+') do
  table.insert(A, tonumber(n))
end
local result = math.max(table.unpack(A)) - math.min(table.unpack(A))
io.write(result .. '\n')
