#include <bits/stdc++.h>
using namespace std;
template <typename T>
void input(vector<T> &arr, long long int n) {
  T temp;
  for (long long int i = 0; i < n; i++) cin >> temp, arr.push_back(temp);
}
template <typename T>
void output(vector<T> arr) {
  for (auto x : arr) cout << x << " ";
  cout << endl;
}
template <typename T>
void input_set(set<T> &arr, long long int n) {
  T temp;
  for (long long int i = 0; i < n; i++) cin >> temp, arr.insert(temp);
}
long long int mul(long long int a, long long int b) {
  return (a % 1000000007 * b % 1000000007) % 1000000007;
}
long long int power(long long int a, long long int b) {
  long long int ans = 1;
  while (b > 0) {
    if (b & 1) ans = mul(ans, a);
    a = mul(a, a);
    ;
    b >>= 1;
  }
  return ans;
}
void solve() {
  int n;
  cin >> n;
  vector<long long int> arr;
  input(arr, n);
  vector<long long int> suffix(n, 0), prefix(n, 0);
  long long int sum = 0, total_sum = 0;
  for (int i = 0; i < n; i++) {
    total_sum += arr[i];
    if (i % 2 == 0) {
      sum += arr[i];
      prefix[i] = total_sum - sum;
    } else {
      prefix[i] = sum;
    }
  }
  total_sum = 0, sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    total_sum += arr[i];
    if (i % 2 == 0) {
      sum += arr[i];
      suffix[i] = total_sum - sum;
    } else {
      suffix[i] = sum;
    }
  }
  long long int ans = arr[0];
  if (n == 1) {
    cout << ans << endl;
    return;
  }
  for (int i = 0; i < n - 1; i++) {
    int left = i - 1;
    int right = i + 2;
    long long int cost = arr[i] + arr[i + 1];
    if (left >= 0) cost += prefix[left];
    if (right < n) cost += suffix[right];
    ans = max(ans, cost);
  }
  ans = max(ans, arr[n - 1] + prefix[n - 2]);
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int testcases = 1;
  while (testcases--) {
    solve();
  }
}
