#include <bits/stdc++.h>
using namespace std;
long long even[222222] = {0}, a[222222], odd[222222] = {0}, backEven[222222],
          cur, best = numeric_limits<int>::min(), besteven = 0;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) cin >> a[i];
  even[1] = 0;
  odd[1] = 0;
  for (int i = 2; i <= n; i++) {
    even[i] = even[i - 1] + (a[i] / 2) * 2;
    if (a[i] < 2) even[i] = 0;
    odd[i] = odd[i - 1] + a[i];
    if (a[i] % 2 == 0) odd[i]--;
  }
  backEven[n] = 0;
  for (int i = n - 1; i >= 1; i--) {
    backEven[i] = backEven[i + 1] + (a[i + 1] / 2) * 2;
    if (a[i + 1] < 2) backEven[i] = 0;
  }
  for (int j = 1; j <= n; j++) {
    cur = besteven + backEven[j] + odd[j];
    best = max(cur, best);
    besteven = max(besteven, even[j + 1] - odd[j + 1]);
  }
  cout << best;
  return 0;
}
