#include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,b) for(int i=a;i<(int)b;i++) #define rep(i,n) REP(i,0,n) typedef long long ll; int main() { int N; cin >> N; int v[N]; rep(i, N) { cin >> v[i]; } ll dp[3]; dp[0] = 0, dp[1] = v[0]; dp[2] = max(v[0], v[1]); REP(i, 3, N+1) { dp[i%3] = max(dp[(i-1)%3], dp[(i-2)%3]+v[i-1]); } cout << dp[N%3] << endl; return 0; }