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