#include using namespace std; const int MAX_N = 1010; int N; vector taste; int dp[MAX_N][2];//0 not 1 use int pre[MAX_N][2]; int main(){ cin >> N; memset(pre, -1, sizeof(pre)); taste.resize(N); for (int i = 0; i < N; i++){ cin >> taste[i]; } int res = 0; for (int i = 0; i < N; i++){ dp[i + 1][1] = max(dp[i + 1][1], dp[i][0]); dp[i + 1][0] = max(dp[i + 1][0], max(dp[i][0], dp[i][1] + taste[i])); res = max(dp[i + 1][1], dp[i + 1][0]); } int pos = N; vector ans; while (true){ if (dp[pos][1] < dp[pos][0]){ ans.push_back(pos); pos -= 2; }else{ pos--; } if (pos < 1)break; } sort(ans.begin(), ans.end()); cout << res << endl; }