#include #define rep(i, n, s) for(int (i) = 0; (i) < (n); (i) += (s)) using namespace std; int main() { int num, result = 0; cin >> num; vector v(num + 5, 0); for (int i = 0; i < num; i++) { int tmp; cin >> tmp; v[i] = tmp; } for (int i = 0; i < num; i++) { if ((v[i] + v[i + 2]) > (v[i + 1] + v[i + 3])) { result += v[i]; i++; } } cout << result << endl; }