#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 5;
int n, a[MAXN];
long long Left[MAXN], Right[MAXN], fL[MAXN], fR[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = (1), b_ = (n - 1); i <= b_; ++i) cin >> a[i];
  Left[1] = fL[1] = 0;
  for (int i = (2), b_ = (n); i <= b_; ++i) {
    if (a[i - 1] >= 2) {
      Left[i] = max(Left[i - 1], fL[i - 1]) + a[i - 1] + (a[i - 1] & 1) - 1;
      fL[i] = fL[i - 1] + a[i - 1] - (a[i - 1] & 1);
    } else
      Left[i] = max(Left[i - 1], fL[i - 1]) + 1;
  }
  Right[n] = fR[n] = 0;
  for (int i = (n - 1), b_ = (1); i >= b_; --i) {
    if (a[i] >= 2) {
      Right[i] = max(Right[i + 1], fR[i + 1]) + a[i] + (a[i] & 1) - 1;
      fR[i] = fR[i + 1] + a[i] - (a[i] & 1);
    } else
      Right[i] = max(Right[i + 1], fR[i + 1]) + 1;
  }
  long long res = 0;
  for (int i = (1), b_ = (n); i <= b_; ++i) {
    res = max(res, max(Left[i] + fR[i], Right[i] + fL[i]));
    res = max(res, fL[i] + fR[i]);
  }
  cout << res << endl;
  return 0;
}
