n=gets.to_i b=[] n.times do b<< gets.to_i end l, r=1, 10**18 b.each_with_index do |e, i| if i.even? l, r=[1, e-r].max, e-l else l, r=[1, l-e].max, r-e end raise unless l<=r end if l>r puts (-1) exit(0) end a=[l] (n-1).downto 0 do |i| if (i+1).even? a<< b[i]+a.last else a<< b[i]-a.last end raise unless a.last>0 end puts a.size a.reverse.map{|e| puts e}