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