#include #include void solve() { int n; std::cin >> n; if (n == 1) { int x; std::cin >> x; std::cout << x << std::endl; return; } int a, b; std::cin >> a >> b; b = std::max(a, b); n -= 2; while (n--) { int x; std::cin >> x; int c = std::max(a + x, b); a = b; b = c; } std::cout << std::max(a, b) << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }