#include #include #include using namespace std; int main(){ int n; cin >> n; vector v(n); for(int i=0; i> v[i]; } vector> cache(n+3, vector(2, 0)); for(int i=n-1; i>=0; --i){ cache[i][false]=max( max(cache[i+1][false], cache[i+1][true]), max(cache[i+2][false], cache[i+2][true])); cache[i][true]=max( max(cache[i+2][false], cache[i+2][true]), max(cache[i+3][false], cache[i+3][true]))+v[i]; } cout << max(cache[0][true], cache[0][false]) << endl; return 0; }