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