#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LLINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = 1.0 / 0.0f;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int MOD = 1000000007;
inline int LC(int x) { return x << 1; }
inline int RC(int x) { return (x << 1) | 1; }
inline bool eq0(double x) { return fabs(x) < eps; }
inline bool eq(double x, double y) { return fabs(x - y) < eps; }
inline bool ls(double x, double y) { return x + eps < y; }
inline bool gr(double x, double y) { return x - eps > y; }
inline bool greq(double x, double y) { return x + eps >= y; }
inline bool lseq(double x, double y) { return x - eps <= y; }
inline double fmax(double x, double y) { return gr(x, y) ? x : y; }
inline double fmin(double x, double y) { return ls(x, y) ? x : y; }
template <class T>
inline T sqr(T x) {
  return x * x;
}
const int MAXN = 100010;
long long a[MAXN];
long long lr[MAXN], lnr[MAXN];
long long rr[MAXN], rnr[MAXN];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    if (a[i - 1] > 1) {
      lr[i] = lr[i - 1] + a[i - 1];
      if (a[i - 1] & 1) lr[i]--;
    }
    if (a[i - 1] > 0) {
      lnr[i] = lnr[i - 1] + a[i - 1];
      if (!(a[i - 1] & 1)) lnr[i]--;
    }
    lnr[i] = max(lnr[i], lr[i]);
  }
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] > 1) {
      rr[i] = rr[i + 1] + a[i];
      if (a[i] & 1) rr[i]--;
    }
    if (a[i] > 0) {
      rnr[i] = rnr[i + 1] + a[i];
      if (!(a[i] & 1)) rnr[i]--;
    }
    rnr[i] = max(rnr[i], rr[i]);
  }
  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    ans = max(ans, lr[i] + rr[i]);
    ans = max(ans, lr[i] + rnr[i]);
    ans = max(ans, rr[i] + lnr[i]);
  }
  cout << ans << endl;
  return 0;
}
