#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
long long l[maxn], r[maxn], dis[maxn];
int n;
long long a[maxn];
int cal(int x) {
  if (x % 2) return x - 1;
  return x;
}
set<long long> s;
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n - 1; i++) {
    if (a[i] > 1) {
      l[i] = l[i - 1] + cal(a[i]);
    }
  }
  for (int i = n - 2; i >= 0; i--) {
    if (a[i + 1] > 1) {
      r[i] = r[i + 1] + cal(a[i + 1]);
    }
  }
  dis[1] = cal(a[1] - 1) + 1;
  for (int i = 2; i < n; i++) {
    dis[i] += (dis[i - 1] + cal(a[i] - 1) + 1);
  }
  long long ans = l[0] + r[0];
  s.insert(l[0]);
  for (int i = 1; i < n; i++) {
    s.insert(l[i] - dis[i]);
    long long x = *--s.lower_bound(1LL * 1e16);
    ans = max(ans, r[i] + dis[i] + x);
  }
  cout << ans;
  return 0;
}
