gets a = gets.chomp.split.map(&:to_i).reverse (a.size-3).times do |i| a[i+2] += a[i] a[i] -= a[i] end a = a.reverse[0,4] a.pop while a.last == 0 && a.size > 1 puts a.size-1 puts a.join(" ")