n=gets.to_i a=[] n.times do |i| a<< gets.to_i end c=0 e=0 while true do b=[] b<< 1+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==10 p -1 break end c=0 n.times do |i| c+=b[i] if 1>b[i] end e+=1 end