#include <bits/stdc++.h>
using namespace std;
int n;
int a[100010];
long long f1[100010];
long long f0[100010];
long long g1[100010];
long long g0[100010];
long long res;
void xuli() {
  for (int i = 2; i <= n; i++) {
    int x;
    if (a[i - 1] % 2 == 0)
      x = a[i - 1];
    else
      x = a[i - 1] - 1;
    if (x > 0) f1[i] = f1[i - 1] + x;
    if (a[i - 1] % 2 == 0) {
      x = a[i - 1] - 1;
      if (f0[i - 1] > 0) f0[i] = f0[i - 1] + x;
    } else {
      x = a[i - 1];
      f0[i] = f0[i - 1] + x;
    }
    if (a[i - 1] % 2 == 1) {
      if (a[i - 1] + f1[i - 1] > f0[i]) f0[i] = a[i - 1] + f1[i - 1];
    }
  }
  return;
}
void xuli2() {
  for (int i = n - 1; i >= 1; i--) {
    int x;
    if (a[i] % 2 == 0)
      x = a[i];
    else
      x = a[i] - 1;
    if (x > 0) g1[i] = g1[i + 1] + x;
    if (a[i] % 2 == 0) {
      x = a[i] - 1;
      if (g0[i + 1] > 0) g0[i] = g0[i + 1] + x;
    } else {
      x = a[i];
      g0[i] = g0[i + 1] + x;
    }
    if (a[i] % 2 == 1) {
      if (a[i] + g1[i + 1] > g0[i]) g0[i] = a[i] + g1[i + 1];
    }
  }
  return;
}
void inkq() {
  res = 0;
  for (int i = 1; i <= n; i++) {
    long long x1 = f0[i] + g1[i] - 1;
    long long x2 = g0[i] + f1[i] - 1;
    long long x3 = f1[i] + g1[i] - 1;
    res = max(res, max(x1, max(x2, x3)) - 1);
  }
  return;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n - 1; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    f1[i] = 1;
    f0[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    g1[i] = 1;
    g0[i] = 0;
  }
  xuli();
  xuli2();
  inkq();
  cout << res;
  return 0;
}
