#include #include #include #include #include #include #include #include #include #define ALL(obj) (obj).begin(),(obj).end() #define RALL(obj) (obj).rbegin(),(obj).rend() #define P pair #define MOD 1000000007 #define INF 1012345678 #define NINF (-2147483647-1) #define LLINF 9223372036854775807 using ll = long long; using namespace std; int N; int memo[1010]; int f(int p, vector V) { if (memo[p] < INF) { return memo[p]; } if (p < N) { return max(f(p + 1, V), f(p + 2, V) + V[p]); } return 0; } int main() { cin >> N; vector V(N); fill(memo, memo + 1010, INF); for (int i = 0; i < N; i++) { cin >> V[i]; } cout << f(0, V) << endl; getchar(); getchar(); return 0; }