n=gets.to_i a=[] n.times do |i| a<< gets.to_i end c=1 e=0 while true do b=[] b<< 2-c (n/2).times do |i| b<< a[i*2]-b[i*2] b<< b[i*2+1]-a[i*2+1] end (n%2).times do b<< a[-1]-b[-1] end if b.all?{|i|i>0} puts n+1,b.*("\n") break elsif e==1 p -1 break end c=1 (n+1).times do |i| c=b[i] if c>b[i] end e+=1 end