#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
inline string get() {
  char ch[2000010];
  scanf("%s", ch);
  return ch;
}
const int MAX_LG = 21;
const long long maxn = 1e5 + 10;
const long long maxm = 1e4;
const long long base = 29;
const long long mod = 1e9 + 7;
const long long INF = 1e18 + 100;
long long pref[maxn], suf[maxn];
long long a[maxn];
long long res;
long long maxi;
int32_t main() {
  long long n = in();
  for (long long i = 1; i < n; i++) a[i] = in();
  for (long long i = 2; i <= n; i++) {
    pref[i] = a[i - 1] <= 1 ? 0 : pref[i - 1] + (a[i - 1] - bool(a[i - 1] % 2));
  }
  for (long long i = n - 1; i >= 1; i--)
    suf[i] = a[i] <= 1 ? 0 : suf[i + 1] + (a[i] - bool(a[i] % 2));
  long long cnt = 0;
  for (long long j = 1; j <= n; j++) {
    if (j != 1) cnt += (a[j - 1] - (a[j - 1] % 2 == 0));
    maxi = max(maxi, pref[j] - cnt);
    res = max(res, suf[j] + cnt + maxi);
  }
  cout << res << "\n";
}
