#include <bits/stdc++.h>
using namespace std;
int n;
long long rght[100000], rback[100000], lft[100000], lback[100000], ans,
    a[100000];
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; ++i) cin >> a[i];
  for (int i = n - 2; i >= 0; --i) {
    if (a[i] & 1)
      rght[i] = a[i] + max(rght[i + 1], rback[i + 1]);
    else
      rght[i] = a[i] - 1 + max(rght[i + 1], rback[i + 1]);
    if (a[i] > 1) {
      if (a[i] & 1)
        rback[i] = a[i] - 1 + rback[i + 1];
      else
        rback[i] = a[i] + rback[i + 1];
    }
  }
  for (int i = 1; i < n; ++i) {
    if (a[i - 1] & 1)
      lft[i] = a[i - 1] + max(lft[i - 1], lback[i - 1]);
    else
      lft[i] = a[i - 1] - 1 + max(lft[i - 1], lback[i - 1]);
    if (a[i - 1] > 1) {
      if (a[i - 1] & 1)
        lback[i] = a[i - 1] - 1 + lback[i - 1];
      else
        lback[i] = a[i - 1] + lback[i - 1];
    }
  }
  for (int i = 0; i < n; ++i) {
    ans = max(ans, lback[i] + rback[i]);
    ans = max(ans, lback[i] + rght[i]);
    ans = max(ans, lft[i] + rback[i]);
  }
  cout << ans << endl;
  return 0;
}
