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