#include #include #include #include #include #include #include #include #include #include #define For(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) For(i,0,n) //clear memory #define CLR(a) memset((a), 0 ,sizeof(a)) #define check(a) rep(i, a.size()) cout << a[i] << endl #define SORT(c) sort((c).begin(),(c).end()) using namespace std; int main(int argc, char* argv[]){ int n; cin >> n; vector v(n + 1); rep(i, n + 1){ cin >> v[i]; } for (int i = n; i > 2; i--){ if (v[i] == 0) continue; v[i - 2] += v[i]; v[i] = 0; } int count = 0; rep(i, n + 1){ if (v[i] != 0) count++; } if (count == 0)cout << 0 << endl << 0 << endl; else cout << count - 1 << endl; for (int i = 0; i < count; i++){ cout << v[i]; if (i == count - 1){ cout << endl; break; }cout << " "; } return 0; }