#include using namespace std; #define REP(i, n) for(int i = 0; i < n; i++) #define FOR(i, m, n) for(int i = m; i < n; i++) int main() { int n; cin >> n; vector value(n); REP(i, n) cin >> value[i]; int dp[1001] = {}; dp[0] = value[0]; dp[1] = max(value[0], value[1]); FOR(i, 2, n) { dp[i] = max(dp[i - 1], dp[i - 2] + value[i]); } cout << dp[n - 1] << endl; return 0; }