#include <bits/stdc++.h>
using namespace std;
int max_even(int x) { return x - x % 2; }
int max_odd(int x) { return x - (x + 1) % 2; }
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> T(n - 1);
  for (int i = (0); i <= ((int)(T).size() - 1); ++i) cin >> T[i];
  vector<pair<long long int, long long int> > pref(n, make_pair(0, 0)),
      suff(n, make_pair(0, 0));
  for (int i = (1); i <= (n - 1); ++i) {
    pref[i].first = pref[i - 1].first + max_odd(T[i - 1]);
    pref[i].second =
        ((T[i - 1] == 1) ? 0 : pref[i - 1].second + max_even(T[i - 1]));
  }
  for (int i = (n - 2); i >= (0); --i) {
    suff[i].first = suff[i + 1].first + max_odd(T[i]);
    suff[i].second = ((T[i] == 1) ? 0 : suff[i + 1].second + max_even(T[i]));
  }
  long long int bestLeft = 0, best = 0;
  for (int i = (0); i <= (n - 1); ++i) {
    long long int L = pref[i].second - pref[i].first,
                  R = suff[i].second - suff[i].first;
    best = max(best, R + bestLeft + pref[n - 1].first);
    bestLeft = max(bestLeft, L);
  }
  cout << best;
  return 0;
}
