#include #include using namespace std; #define REP(i,first,last) for (int i=first;i multi; int main(){ cin >> D; int val; REP(i,0,D + 1) { cin >> val; multi.push_back(val); } for (int i=multi.size() - 1;i>=3;i--) { if (multi[i] != 0) { multi[i-2] += multi[i]; multi[i] = 0; } } int top_idx = 0; for (int i=multi.size() - 1;i>=0;i--) { if (multi[i] != 0) { top_idx = i; break; } } cout << top_idx << endl; for (int i=0;i<=top_idx;i++) { if (i == 0) { cout << multi[i]; } else { cout << " " << multi[i]; } } cout << endl; }