#include <bits/stdc++.h>
using namespace std;
template <class Ta, class Tb>
inline Tb cast(Ta a) {
  stringstream ss;
  ss << a;
  Tb b;
  ss >> b;
  return b;
};
const double EPS = 1e-9;
const int INF = 1000000000;
const int MOD = 1000000007;
const int diri[8] = {-1, 0, 1, 0, -1, 1, 1, -1};
const int dirj[8] = {0, 1, 0, -1, 1, 1, -1, -1};
void fun(vector<int> v, vector<pair<long long, long long> >& u) {
  int n = v.size();
  u = vector<pair<long long, long long> >(n + 1);
  u[0] = pair<long long, long long>(0, 0);
  for (int i = 1; i <= n; ++i) {
    int t = v[i - 1];
    int t1 = t - 1 + t % 2;
    int t2 = t - t % 2;
    long long a = 0, b = 0;
    if (t > 0) {
      a = max(t1 + u[i - 1].first, t2 + u[i - 1].second);
    }
    if (t > 1) {
      b = t2 + u[i - 1].second;
    }
    u[i] = pair<long long, long long>(a, b);
  }
}
int main() {
  int n;
  cin >> n;
  --n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  vector<pair<long long, long long> > u1;
  fun(v, u1);
  vector<pair<long long, long long> > u2;
  reverse(v.begin(), v.end());
  fun(v, u2);
  reverse(u2.begin(), u2.end());
  long long res = 0;
  for (int i = 0; i <= n; ++i) {
    res = max(res, max(u1[i].first + u2[i].second, u1[i].second + u2[i].first));
  }
  cout << res << endl;
}
