d = gets.to_i an = gets.split.map(&:to_i) m = [1,0,1,0] (an.size - 1).downto(3).each do |i| an[i-2] += an[i] an[i] = 0 end an.pop while an.last == 0 and an.size > 1 puts an.size - 1 puts an.join(' ')