#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]; i64 max = -inf; for (int i = 1; i < n; ++i) { dp[i] = a[i]; if (i - 2 >= 0) { max = std::max(max, dp[i - 2]); dp[i] = std::max(dp[i], dp[i] + max); } } std::cout << dp[n - 1] << '\n'; return 0; }