#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 f(int p, vector V) { if (p < N) { return max(f(p + 1, V), f(p + 2, V) + V[p]); } else { return 0; } } int main() { cin >> N; vector V(N); for (int i = 0; i < N; i++) { cin >> V[i]; } cout << f(0, V) << endl; getchar(); getchar(); return 0; }