#include <bits/stdc++.h>
using namespace std;
const int maxn = 100050;
long long flg[maxn], flb[maxn], frb[maxn], frg[maxn];
int p[maxn];
int maxodd(const int &x) { return x - ((x ^ 1) & 1); }
int maxeven(const int &x) { return x - (x & 1); }
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i < n; ++i) cin >> p[i];
  for (int i = 2; i <= n; ++i) {
    if (p[i - 1]) flg[i] = max(flb[i - 1], flg[i - 1]) + maxodd(p[i - 1]);
    if (p[i - 1] >= 2) flb[i] = flb[i - 1] + maxeven(p[i - 1]);
  }
  for (int i = n - 1; i >= 1; --i) {
    if (p[i]) frg[i] = max(frb[i + 1], frg[i + 1]) + maxodd(p[i]);
    if (p[i] >= 2) frb[i] = frb[i + 1] + maxeven(p[i]);
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans = max(ans, flb[i] + frg[i]);
    ans = max(ans, flb[i] + frb[i]);
    ans = max(ans, frb[i] + flg[i]);
  }
  cout << ans << endl;
  return 0;
}
