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