#include using namespace std; #define int long long signed main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector v(n); for(int i = 0; i < n; i++){ cin >> v[i]; } if(n < 2){ cout << v[0] << endl; return 0; } vector dp(n); dp[0] = v[0]; dp[1] = v[1]; if(n > 2) dp[2] = v[0] + v[2]; for(int i = 3; i < n; i++){ dp[i] = max(dp[i-2],dp[i-3]) + v[i]; } cout << max(dp[n-1],dp[n-2]) << endl; return 0; }