#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[N+1][2]; rep(i, N+1) rep(j, 2) dp[i][j] = 0; dp[0][0] = 1; REP(i, 1, N+1) { rep(j, i) { if(j < i-1) dp[i][0] = max({dp[i][0], dp[j][0] + v[i-1], dp[j][1] + v[i-1]}); else { dp[i][1] = max(dp[i][1], dp[j][0] + v[i-1]); } } } cout << max(dp[N][0], dp[N][1]) << endl; return 0; }