#include using namespace std; int n; vector v; vector sum; int max_sum(int i) { if (sum[i] == -1) { int m = 0, m2 = 0; if (i + 2 < n) m = max_sum(i + 2); if (i + 3 < n) m2 = max_sum(i + 3); sum[i]=v[i] + max(m, m2); } return sum[i]; } int main() { cin >> n; v.resize(n); sum.resize(n); for (int i = 0;i < n;i++) { cin >> v[i]; sum[i] = -1; } if (n > 1) cout << max(max_sum(0), max_sum(1)) << endl; else cout << max_sum(0) << endl; return 0; }