#include #include int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int d; std::vector a; int result_rank = 0; std::cin >> d; for (int i = 0; i <= d; ++i) { int tmp; std::cin >> tmp; a.push_back(tmp); } if (d <= 2) { result_rank = d; std::cout << d << "\n"; } else { for (auto rit = a.rbegin(); rit != a.rend() - 3; ++rit) { *(rit + 2) += (*rit); *rit = 0; } for (int i = 2; i > 0; --i) { if (a[i] != 0) { result_rank = i; std::cout << i << "\n"; break; } } if (result_rank == 0) { std::cout << 0 << "\n"; } } for (int i = 0; i <= result_rank; ++i) { std::cout << a[i] << " "; } std::cout << "\n"; return 0; }