#include <bits/stdc++.h>
using namespace std;
int n;
int a[200005];
long long l[200005], r[200005], sumOdd[200005];
void doc() {
  cin >> n;
  for (int i = 1; i <= n - 1; i++) cin >> a[i];
}
void xuly() {
  l[1] = 0;
  for (int i = 2; i <= n; i++) {
    int u = a[i - 1];
    if (u % 2 == 1) u--;
    if (u == 0)
      l[i] = 0;
    else
      l[i] = l[i - 1] + u;
  }
  r[n] = 0;
  for (int i = n - 1; i >= 1; i--) {
    int u = a[i];
    if (u % 2 == 1) u--;
    if (u == 0)
      r[i] = 0;
    else
      r[i] = r[i + 1] + u;
  }
  sumOdd[1] = 0;
  for (int i = 2; i <= n; i++) {
    int u = a[i - 1];
    if (u % 2 == 0) u--;
    sumOdd[i] = sumOdd[i - 1] + u;
  }
  long long maxx = -1000000000000000000LL;
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    maxx = max(maxx, l[i] - sumOdd[i]);
    res = max(res, maxx + r[i] + sumOdd[i]);
  }
  cout << res;
}
int main() {
  doc();
  xuly();
}
