#include #include #include #define REP(i, n) for(int i = 0; i < (int)(n); i++) #define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i) #define print(x) cout << x << endl; using namespace std; int main(void){ cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector V(N); REP(i, N) cin >> V[i]; vector dp(N); dp[0] = V[0]; if(N != 1) { dp[1] = max(V[0], V[1]); FOR(i, 2, N){ dp[i] = max(dp[i-1], dp[i-2] + V[i]); } } print(dp[N-1]); return 0; }