#include using namespace std; typedef long long ll; const double PI = acos(-1); const ll MOD = 1000000007; int main() { int N; cin >> N; vector V(N); for (int i = 0; i < N; i++) cin >> V[i]; vector ans(N); for (int i = 0; i < N; i++) { if (i == 0) ans[i] = V[i]; else if (i == 1) ans[i] = max(V[i],V[i-1]); else ans[i] = max(ans[i-1],ans[i-2]+V[i]); } cout << ans[N-1] << endl; }