#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
long long lef[N], righ[N];
long long sumOdd[N];
long long a[N];
int n;
void init() {
  sumOdd[1] = 0;
  for (int i = 1; i < n; i++) {
    sumOdd[i + 1] = sumOdd[i] + a[i] - (a[i] % 2 == 0 ? 1 : 0);
  }
  lef[1] = 0;
  for (int i = 1; i < n; i++) {
    lef[i + 1] = lef[i] + a[i] - (a[i] % 2 == 1 ? 1 : 0);
    if (a[i] < 2) lef[i + 1] = 0;
  }
  righ[n] = 0;
  for (int i = n - 1; i >= 1; i--) {
    righ[i] = righ[i + 1] + a[i] - (a[i] % 2 == 1 ? 1 : 0);
    if (a[i] < 2) righ[i] = 0;
  }
}
long long best[N];
int main() {
  while (cin >> n) {
    for (int i = 1; i < n; i++) cin >> a[i];
    memset(righ, 0, sizeof(righ));
    memset(lef, 0, sizeof(lef));
    memset(sumOdd, 0, sizeof(sumOdd));
    init();
    long long mxi = -1;
    long long mxj = -1;
    long long res = 0;
    best[0] = 0;
    int idi = -1, idj = -1;
    for (int i = 1; i <= n; i++) {
      if (mxi < lef[i] - sumOdd[i]) {
        mxi = lef[i] - sumOdd[i];
        idi = i;
      }
      best[i] = mxi;
      if (res < best[i] + righ[i] + sumOdd[i]) {
        res = best[i] + righ[i] + sumOdd[i];
        idj = i;
      }
    }
    cout << res << endl;
  }
  return 0;
}
