local n = tonumber(io.read());
local input = {}

for v in string.gmatch(io.read(), "(%d+)") do
    table.insert(input, tonumber(v));
end

table.sort(input, function(a, b)
    return a < b;
end)

local result = input[#input] - input[1];
print(result);
