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