#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
int n;
long long a[N], l[N], r[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n - 1; ++i) cin >> a[i];
  long long tmp;
  l[1] = 0;
  for (int i = 2; i <= n; ++i) {
    tmp = (a[i - 1] % 2 == 0) ? a[i - 1] : a[i - 1] - 1;
    if (a[i - 1] >= 2) l[i] = l[i - 1] + tmp;
  }
  r[n] = 0;
  for (int i = n - 1; i >= 1; --i) {
    tmp = (a[i] % 2 == 0) ? a[i] : a[i] - 1;
    if (a[i] >= 2) r[i] = r[i + 1] + tmp;
  }
  tmp = 0;
  long long delta;
  long long res = 0;
  for (int i = n - 1; i >= 1; --i) {
    delta = (a[i] % 2 == 0) ? a[i] - 1 : a[i];
    tmp = max(tmp + delta, r[i]);
    res = max(res, l[i] + tmp);
  }
  cout << res;
}
