d = io.read("*n") a = {} for i = 0, d do a[i] = io.read("*n") end for i = d, 3, -1 do a[i - 2] = a[i - 2] + a[i] end if(a[2] ~= nil and a[2] ~= 0) then print(2) print(a[0] .. " " .. a[1] .. " " .. a[2]) elseif(a[1] ~= nil and a[1] ~= 0) then print(1) print(a[0] .. " " .. a[1]) else print(0) print(a[0]) end