#include using namespace std; using ll = long long; using ld = long double; #define rep(i, r) for(int i = 0; i < (r); ++i) #define reps(i, s, r) for(int i = (s); i < (r); ++i) #define fore(i, m2) for(auto &i : m2) #define vi vector #define vl vector #define pl pair #define all(i) (i).begin(), (i).end() #define fs first #define sc second template bool chmin(T &i, T b) { if(i > b) { i = b; return true; } return false; } template bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } const ll INF = LONG_LONG_MAX / 3; const ll MOD = 1'000'000'007; const ll MAX = 2e5 + 5; int main() { ll n; cin >> n; vl a(n), dp(n + 3); rep(i, n) cin >> a[i]; dp[0] = a[0]; dp[1] = max(a[0], a[1]); reps(i, 2, n) { ll add = 0; if(i >= 2) dp[i] = max(dp[i - 1], dp[i - 2] + a[i]); } cout << dp[n - 1] << endl; }