#include <bits/stdc++.h>
using namespace std;
int n, a[100111];
long long lf[100111], sumOdd[100111], res = 0LL;
int main() {
  scanf("%d", &n);
  for (int i = 0, _n = (n - 1); i < _n; i++) scanf("%d", &a[i]);
  lf[0] = sumOdd[0] = 0;
  for (int i = (1), _b = (n); i <= _b; i++) {
    if (a[i - 1] <= 1)
      lf[i] = 0;
    else
      lf[i] = lf[i - 1] + (a[i - 1] / 2) * 2;
    int odd = a[i - 1];
    if (a[i - 1] % 2 == 0) odd = max(0, odd - 1);
    sumOdd[i] = sumOdd[i - 1] + odd;
  }
  long long curRg = 0, maxRg = sumOdd[n], prevRg = 0;
  for (int i = (n - 1), _b = (0); i >= _b; i--) {
    if (a[i] <= 1)
      curRg = 0;
    else
      curRg = prevRg + (a[i] / 2) * 2;
    maxRg = max(maxRg, curRg + sumOdd[i]);
    res = max(res, maxRg + lf[i] - sumOdd[i]);
    prevRg = curRg;
  }
  cout << res << endl;
  return 0;
}
