#include #include using namespace std; template bool chmax(T &a, T b) { if (a < b) { a = b; return true; } else { return false; } } int main() { int N; cin >> N; vector V(N); for (int i = 0; i < N; ++i) cin >> V[i]; vector dp(N + 1, -1); dp[0] = 0; dp[1] = V[0]; for (int i = 2; i <= N; ++i) { chmax(dp[i], dp[i - 2] + V[i - 1]); chmax(dp[i], dp[i - 1]); } cout << dp[N] << endl; }