#include <bits/stdc++.h>
using namespace std;
int n;
long long izq[100009], der[100009], impar[100009];
long long num[100009];
long long maxpar(long long value) { return value - value % 2; }
long long maximpar(long long value) {
  if (value % 2)
    return value;
  else
    return value - 1;
}
long long suma(int i, int j) { return impar[j] - impar[i]; }
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> num[i];
  }
  for (int i = 2; i <= n; i++) {
    izq[i] = izq[i - 1] + maxpar(num[i - 1]);
    if (num[i - 1] == 1) izq[i] = 0;
  }
  for (int i = n - 1; i >= 1; i--) {
    der[i] = der[i + 1] + maxpar(num[i]);
    if (num[i] == 1) der[i] = 0;
  }
  for (int i = 2; i <= n; i++) {
    impar[i] = impar[i - 1] + maximpar(num[i - 1]);
  }
  long long t = 0;
  long long res = 0;
  for (int j = 1; j <= n; j++) {
    t = max(t, izq[j] - impar[j]);
    res = max(res, impar[j] + der[j] + t);
  }
  cout << res << endl;
  return 0;
}
