require 'pp' def divide(poly, div) c = poly[-1] / div[-1] _poly = [] len = poly.length len.times{|d| if len - d < div.length _poly[d] = poly[d] - c * div[div.length - (len - d)] else _poly[d] = poly[d] end } while _poly[-1] == 0 _poly.pop() end return _poly end d = gets.to_i poly = gets.strip.split.map{|e| e.to_i} div = [0, -1, 0, 1] while div.length <= poly.length poly = divide(poly, div) end if poly.empty? puts 0 puts 0 else puts (poly.length - 1) puts poly.join(' ') end