local function fsum(...)
local p, abs = {1}, math.abs
local function fadd(x)
local p, i = p, 2
for j = 2, p[1] do
local y = p[j]
if abs(x) < abs(y) then x, y = y, x end
local hi = x + y
local lo = y - (hi - x)
x = hi
if lo ~= 0 then p[i] = lo; i = i + 1 end
end
if i > p[1] then i = p[1] + 1 end
if x - x ~= 0 then i = 2 end
p[1] = i
p[i] = x
end
local function ftotal(clear)
local p, x = p, 0
if clear then p[1] = 1 end
for i = p[1], 2, -1 do
local y = p[i]
local hi = x + y
local lo = y - (hi - x)
x = hi
if lo ~= 0 and i ~= 2 then
if (lo < 0) == (p[i-1] < 0) then
lo = lo * 2
hi = x + lo
if lo == hi - x then x = hi end
end
return x
end
end
return x
end
if select('#', ...) == 0 then return fadd, ftotal end
for i = 1, select('#', ...) do fadd(select(i, ...)) end
return ftotal()
end
if select(1, ...) ~= 'fsum' then
local read, fadd, ftotal = io.read, fsum()
io.input(select(1, ...))
pcall(function() while true do fadd(read('*n')) end end)
print(ftotal())
end
return fsum