#include <bits/stdc++.h>
using namespace std;
istream &in = cin;
int n;
long long b[100002];
long long L[100002];
long long R[100002];
long long odd[100002];
int main() {
  memset(b, 0, sizeof(b));
  in >> n;
  for (int i = 1; i < n; ++i) in >> b[i];
  L[0] = R[n + 1] = 0;
  for (int i = 1; i <= n; ++i)
    if (b[i - 1] == 1)
      L[i] = 0;
    else
      L[i] = L[i - 1] + b[i - 1] / 2 * 2;
  for (int i = n; i >= 1; --i)
    if (b[i] == 1)
      R[i] = 0;
    else
      R[i] = R[i + 1] + b[i] / 2 * 2;
  for (int i = 1; i < n; ++i) {
    if (b[i] % 2)
      odd[i] = b[i];
    else if (b[i] == 0)
      odd[i] = b[i];
    else
      odd[i] = b[i] - 1;
  }
  long long ret = 0, maxI = 0, sumI = 0, sumJ = 0;
  for (int i = 1; i <= n; ++i) {
    sumI += odd[i - 1];
    maxI = max(maxI, L[i] - sumI);
    sumJ += odd[i - 1];
    ret = max(ret, maxI + sumJ + R[i]);
  }
  cout << ret << endl;
  return 0;
}
