#include <bits/stdc++.h>
using namespace std;
const long long N = 1000010;
long long n, a[N], odd[N], sumOdd[N], Left[N], Right[N], mxcur, ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    if (a[i] <= 0) continue;
    odd[i] = a[i] - !(a[i] % 2);
    sumOdd[i + 1] = sumOdd[i] + odd[i];
  }
  for (int i = 2; i <= n; i++) {
    if (a[i - 1] <= 1) continue;
    Left[i] = Left[i - 1] + a[i - 1] - (a[i - 1] % 2);
  }
  for (int i = n - 1; i >= 1; i--) {
    if (a[i] <= 1) continue;
    Right[i] = Right[i + 1] + a[i] - (a[i] % 2);
  }
  for (int i = 1; i <= n; i++) {
    mxcur = max(Left[i] - sumOdd[i], mxcur);
    ans = max(ans, (Right[i] + sumOdd[i]) + mxcur);
  }
  cout << ans << "\n";
  return 0;
}
