#include #include using namespace std; int main() { int D; vector a; cin >> D; a.resize(D + 1); for (int i = 0; i <= D; ++i) { int tmp; cin >> tmp; a[D - i] = tmp; } while (3 < a.size()) { int first = a[0], second = a[1], third = a[2]; third = third + first; if (second != 0) { a[2] = third; a.erase(a.begin(), a.begin() + 1); } else { a[2] = third; a.erase(a.begin(), a.begin() + 2); } } while (1 < a.size() && a[0] == 0) { a.erase(a.begin(), a.begin() + 1); } cout << a.size() - 1 << endl; for (int i = 0; i < a.size(); ++i) { cout << a[a.size() - 1 - i]; if (i != a.size() - 1) cout << " "; else cout << endl; } return 0; }