#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T bpow(T p, T e) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
int toInt(string s) {
  int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int toLlint(string s) {
  long long int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int ts, kk = 1;
int n;
int a[100005];
long long int lt[100005], rt[100005], sm[100005];
long long int clc(int l, int r) { return sm[r] - sm[l] + lt[l] + rt[r]; }
int main() {
  int t, i, j, k;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i]) {
      sm[i] = sm[i - 1] + (a[i] - 1) + (a[i] & 1);
    } else
      sm[i] = 0;
  }
  lt[0] = 0;
  for (i = 1; i < n; i++) {
    if (a[i] > 1) {
      lt[i] = lt[i - 1] + a[i] - (a[i] & 1);
    } else
      lt[i] = 0;
  }
  rt[n - 1] = 0;
  for (i = n - 2; i > -1; i--) {
    if (a[i + 1] > 1)
      rt[i] = rt[i + 1] + a[i + 1] - (a[i + 1] & 1);
    else
      rt[i] = 0;
  }
  long long int rs = 0, mx = 0;
  int l, r;
  l = 0;
  for (r = 0; r < n; r++) {
    if (lt[r] - sm[r] > lt[l] - sm[l]) l = r;
    rs = max(rs, clc(l, r));
  }
  printf("%lld\n", rs);
  return 0;
}
