gets e=gets.split.map &:to_i d=[0,-1,0,1] until d.size>e.size d.size.times{|i|e[i+e.size-d.size]-=e[-1]/d[-1]*d[i]} e.pop end e.pop until e.size<2||e[-1]!=0 p e.size-1 puts e*' '