#include "bits/stdc++.h" using namespace std; #define mset(a,x) memset(a,x,sizeof(a)) int N; vector V; int dp[1010][2]; int rec(int i, bool fetched) { int &r = dp[i][fetched]; if (r != -1) return r; if (i == N) return r = 0; if (fetched) return r = rec(i + 1, 0); else return r = max(rec(i + 1, 1) + V[i], rec(i + 1, 0)); } int main() { cin >> N; V.resize(N); for (int& v : V) cin >> v; mset(dp, -1); cout << rec(0, 0) << endl; return 0; }