#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int u, v; ll w; }; ll MOD = 1000000007; int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, -1, 0, 1}; int main() { int N; cin >> N; vector V(N + 10); for (int i = 1; i <= N; i++) cin >> V[i]; vector dp(N + 10); dp[1] = V[1]; for (int i = 0; i <= N; i++) { dp[i + 1] = max(dp[i + 1], dp[i]); dp[i + 2] = max(dp[i + 2], dp[i] + V[i + 2]); } cout << dp[N] << endl; }