#include <bits/stdc++.h>
using namespace std;
void solve(const vector<int>& A, vector<long long>& W, vector<long long>& R) {
  for (int i = 0; i < (int)(((int)((A).size()))); ++i)
    if (A[i] % 2 == 0) {
      W[i + 1] = max(A[i] + R[i], A[i] - 1 + W[i]);
      R[i + 1] = A[i] + R[i];
    } else {
      W[i + 1] = A[i] + W[i];
      R[i + 1] = (A[i] == 1) ? 0 : A[i] - 1 + R[i];
    }
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> A(n - 1);
  for (int i = 0; i < (int)(n - 1); ++i) scanf("%d", &A[i]);
  vector<long long> L(n), LS(n);
  solve(A, L, LS);
  reverse(A.begin(), A.end());
  vector<long long> R(n), RS(n);
  solve(A, R, RS);
  reverse(R.begin(), R.end());
  reverse(RS.begin(), RS.end());
  long long res = 0;
  for (int i = 0; i < (int)(n); ++i)
    res = max(res, max(LS[i] + R[i], L[i] + RS[i]));
  cout << res << endl;
}
