#include using namespace std; int main() { int num; cin >> num; vector v(num + 3, 0); for (int i = 0; i < num; ++i) { int tmp; cin >> tmp; v[i] = tmp; } vector vo; vector vx; for (int i = 0; i < num; i += 3) { // oxo vo.push_back(v[i] + v[i + 2]); // xxo vo.push_back(v[i + 2]); // xox vx.push_back(v[i + 1]); // oxx vx.push_back(v[i]); } long long result_o = 0; long long result_x = 0; for (int i = 0; i < vo.size(); i += 2) { result_o += (vo[i] > vo[i+1]) ? vo[i] : vo[i+1]; result_x += (vx[i] > vx[i+1]) ? vx[i] : vx[i+1]; } cout << ((result_o > result_x) ? result_o : result_x) << endl; }