#include <bits/stdc++.h>
using namespace std;
long long a[110000];
long long rRet[110000] = {0};
long long lRet[110000] = {0};
long long rNRet[110000] = {0};
long long lNRet[110000] = {0};
int main() {
  int n;
  cin >> n;
  n--;
  for (int(i) = 0; (i) < (n); (i)++) cin >> a[i];
  rRet[n] = 0;
  rNRet[n] = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] <= 1)
      rRet[i] = 0;
    else
      rRet[i] = rRet[i + 1] + (a[i] / 2 * 2);
    rNRet[i] = rNRet[i + 1] + a[i];
    if (a[i] % 2 == 0) rNRet[i]--;
    rNRet[i] = max(rNRet[i], rRet[i]);
  }
  lRet[0] = lNRet[0] = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i - 1] <= 1)
      lRet[i] = 0;
    else
      lRet[i] = lRet[i - 1] + (a[i - 1] / 2 * 2);
    lNRet[i] = lNRet[i - 1] + a[i - 1];
    if (a[i - 1] % 2 == 0) lNRet[i]--;
    rNRet[i] = max(rNRet[i], rRet[i]);
  }
  long long sum = 0;
  for (int(i) = 0; (i) < (n + 1); (i)++) {
    sum = max(sum, lRet[i] + rNRet[i]);
    sum = max(sum, lNRet[i] + rRet[i]);
  }
  cout << sum << endl;
}
