#include using namespace std; using ll = long long; using vl = vector; #define REP(i,n) for(ll i=0; i<(n); ++i) int main() { ll n; cin >> n; vl v(n); REP(i, n) cin >> v[i]; pair sum = {0,0}; REP(i,n) { sum.first = max(sum.first, sum.second); sum.second += v[i]; swap(sum.first, sum.second); } cout << max(sum.first, sum.second) << endl; return 0; }