#include <bits/stdc++.h>
using namespace std;
int n;
int num[100005];
long long L[100005], R[100005], S[100005];
long long gao() {
  L[0] = 0;
  S[0] = 0;
  for (int i = 1; i < n; i++) {
    if (num[i] == 1) {
      L[i] = 0;
    } else {
      L[i] = L[i - 1] + (num[i] / 2 * 2);
    }
    S[i] = S[i - 1] + ((num[i] - 1) / 2 * 2 + 1);
  }
  R[n - 1] = 0;
  for (int i = n - 2; i >= 1; i--) {
    if (num[i + 1] == 1) {
      R[i] = 0;
    } else {
      R[i] = R[i + 1] + (num[i + 1] / 2 * 2);
    }
  }
  long long ret = 0;
  int i = 0;
  for (int j = 1; j < n; j++) {
    if (L[i] - S[i] < L[j] - S[j]) {
      i = j;
    }
    long long tmp = R[j] + S[j] + L[i] - S[i];
    ret = max(ret, tmp);
  }
  return ret;
}
int main() {
  while (cin >> n) {
    for (int i = 1; i < n; i++) {
      cin >> num[i];
    }
    long long ans = gao();
    cout << ans << endl;
  }
  return 0;
}
