#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int>a(n+1);
  vector<int>dp(n+1);
  int sum = 0;
  int ans = 0;
  for(int i = 1;i<=n;i++) cin >> a[i];
  dp[0] = 0;dp[1] = a[1];
  for(int i = 2;i<=n;i++)
  {
    dp[i] = max(dp[i-2]+a[i],dp[i-1]);
  }
  cout << dp[n];
  return 0;
}