#include <bits/stdc++.h>
using namespace std;
const long long INFll = 1ll * 1000000009 * 1000000009;
long long lf[2][100005], rg[2][100005];
long long a[100005];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) cin >> a[i];
  lf[0][0] = lf[1][0] = 0;
  rg[0][n - 1] = rg[1][n - 1] = 0;
  for (int i = 1; i < n; i++) {
    long long x = a[i - 1];
    if (x % 2) {
      lf[0][i] = max(x + lf[0][i - 1], x - 1 + lf[1][i - 1]);
    } else {
      lf[0][i] = max(x - 1 + lf[0][i - 1], x + lf[1][i - 1]);
    }
    x = a[i - 1];
    if (x == 1) continue;
    if (x % 2) x--;
    lf[1][i] = x + lf[1][i - 1];
  }
  for (int i = n - 2; i >= 0; i--) {
    long long x = a[i];
    if (x % 2) {
      rg[0][i] = max(x + rg[0][i + 1], x - 1 + rg[1][i + 1]);
    } else {
      rg[0][i] = max(x - 1 + rg[0][i + 1], x + rg[1][i + 1]);
    }
    x = a[i];
    if (x == 1) continue;
    if (x % 2) x--;
    rg[1][i] = x + rg[1][i + 1];
  }
  long long ans = 0;
  for (int i = 0; i < n - 1; i++) {
    ans = max(ans, a[i] + lf[0][i] + rg[1][i + 1]);
    ans = max(ans, a[i] + lf[1][i] + rg[0][i + 1]);
  }
  cout << ans << endl;
}
