#include <bits/stdc++.h>
using namespace std;
const int NMAX = 100100;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
long long a[NMAX];
long long dpl[NMAX];
long long dpr[NMAX];
long long dp[NMAX];
long long dpd[NMAX];
int n;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; ++i) {
    cin >> a[i];
  }
  long long e = 0;
  for (int i = 1; i < n; ++i) {
    dp[i + 1] = dp[i] + 1 + ((a[i] - 1) / 2) * 2;
    if (a[i] / 2 == 0) {
      e = 0;
      dpl[i + 1] = 0;
    } else {
      e += (a[i] / 2) * 2;
      dpl[i + 1] = e;
    }
    dpd[i + 1] = max(dpd[i], dpl[i + 1] - dp[i + 1]);
  }
  e = 0;
  long long ans = dp[n];
  ans = max(ans, dpd[n] + dp[n]);
  for (int i = n - 1; i > 0; --i) {
    if (a[i] / 2 == 0) {
      e = 0;
      dpr[i] = 0;
    } else {
      e += (a[i] / 2) * 2;
      dpr[i] = e;
    }
    ans = max(ans, dpr[i] + dp[i] + dpd[i]);
  }
  cout << ans << endl;
  return 0;
}
