#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n;
  cin >> n;
  vector<long long> a(n - 1);
  for (long long i = 0; i < n - 1; ++i) {
    cin >> a[i];
  }
  vector<vector<long long> > fdp(n);
  fdp[n - 1].resize(2);
  fdp[n - 1][0] = fdp[n - 1][1] = 0;
  for (long long i = n - 2; i >= 0; --i) {
    fdp[i].resize(2);
    if (a[i] % 2 == 1) {
      fdp[i][0] = a[i] + fdp[i + 1][0];
      if (a[i] == 1) {
        fdp[i][1] = 0;
      } else {
        fdp[i][1] = a[i] - 1 + fdp[i + 1][1];
      }
    } else {
      fdp[i][0] = max(a[i] + fdp[i + 1][1], a[i] - 1 + fdp[i + 1][0]);
      fdp[i][1] = a[i] + fdp[i + 1][1];
    }
  }
  vector<vector<long long> > bdp(n);
  bdp[0].resize(2);
  bdp[0][0] = fdp[0][1] = 0;
  for (long long i = 1; i < n; ++i) {
    bdp[i].resize(2);
    if (a[i - 1] % 2 == 1) {
      bdp[i][0] = a[i - 1] + bdp[i - 1][0];
      if (a[i - 1] == 1) {
        bdp[i][1] = 0;
      } else {
        bdp[i][1] = a[i - 1] - 1 + bdp[i - 1][1];
      }
    } else {
      bdp[i][0] = max(a[i - 1] + bdp[i - 1][1], a[i - 1] - 1 + bdp[i - 1][0]);
      bdp[i][1] = a[i - 1] + bdp[i - 1][1];
    }
  }
  long long mx = INT_MIN;
  for (long long i = 0; i < n; ++i) {
    mx = max(mx, max(fdp[i][1] + bdp[i][0], bdp[i][1] + fdp[i][0]));
  }
  cout << mx << '\n';
  return 0;
}
