#include using i64 = long long; int main() { std::cin.tie(nullptr)->sync_with_stdio(false); int n; std::cin >> n; std::vector a(n); for (auto &x : a) std::cin >> x; constexpr i64 inf = std::numeric_limits::max() >> 4; std::vector dp(n, -inf); dp[0] = a[0]; for (int i = 1; i < n; ++i) { dp[i] = std::max(dp[i - 1], a[i]); if (i - 2 >= 0) { dp[i] = std::max(dp[i], dp[i - 2] + a[i]); } } std::cout << dp[n - 1] << '\n'; return 0; }