#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[1000005];
long long f1[1000005], g1[1000005];
long long f2[1000005], g2[1000005];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (long long i = 1; i <= n - 1; i++) cin >> a[i];
  for (long long i = n - 1; i >= 1; i--) {
    if (a[i] == 0) continue;
    if (a[i] == 1) {
      f1[i] = f1[i + 1] + 1;
      g1[i] = 0;
    } else {
      if (a[i] % 2 == 0)
        f1[i] = f1[i + 1] + a[i] - 1;
      else
        f1[i] = f1[i + 1] + a[i];
      g1[i] = g1[i + 1] + (a[i] - a[i] % 2);
    }
    f1[i] = max(f1[i], g1[i]);
  }
  for (long long i = 2; i <= n; i++) {
    if (a[i - 1] == 0) continue;
    if (a[i - 1] == 1) {
      f2[i] = f2[i - 1] + 1;
      g2[i] = 0;
    } else {
      if (a[i - 1] % 2 == 0)
        f2[i] = f2[i - 1] + a[i - 1] - 1;
      else
        f2[i] = f2[i - 1] + a[i - 1];
      g2[i] = g2[i - 1] + (a[i - 1] - a[i - 1] % 2);
    }
    f2[i] = max(f2[i], g2[i]);
  }
  long long ans = 0;
  for (long long i = 1; i <= n - 1; i++) {
    ans = max(ans, f2[i] + f1[i]);
  }
  cout << ans << '\n';
}
