#include <bits/stdc++.h>
using namespace std;
long long nt[100005], q[100005], s[100005], t, res;
int n;
int main() {
  cin >> n;
  s[0] = 0;
  for (int i = 1; i < n; i++) {
    cin >> q[i];
    s[i] = s[i - 1] + q[i];
    if (q[i] % 2 == 0) s[i]--;
  }
  t = 0;
  nt[n - 1] = s[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    if (q[i + 1] > 1) {
      t = t + q[i + 1];
      if (q[i + 1] & 1) t--;
    } else
      t = 0;
    nt[i] = max(nt[i + 1], s[i] + t);
  }
  res = nt[0];
  t = 0;
  for (int i = 1; i < n; i++) {
    if (q[i] > 1) {
      t += q[i];
      if (q[i] & 1) t--;
    } else
      t = 0;
    res = max(res, t + nt[i] - s[i]);
  }
  cout << res << endl;
}
