#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define mp make_pair #define mt make_tuple #define pb push_back #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair pii; const int INF=1<<29; const double EPS=1e-9; const int dx[]={1,0,-1,0},dy[]={0,-1,0,1}; int N; vector V; int dp[1010]; int memo(int pos){ if (pos >= N){ return 0; } if (dp[pos] >= 0){ return dp[pos]; } int res = 0; res = max(res, memo(pos + 2) + V[pos]); res = max(res, memo(pos + 1)); return dp[pos] = res; } int main(){ cin >> N; for (int i = 0; i < N; i++){ int x; cin >> x; V.push_back(x); } memset(dp, -1, sizeof(dp)); cout << memo(0) << endl; return 0; }