#include <bits/stdc++.h>
using namespace std;
long long n, ans, a[100010], L[100010][2], R[100010][2];
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    if (a[i - 1] >= 2) L[i][1] = L[i - 1][1] + a[i - 1] - (a[i - 1] & 1);
    L[i][0] = max(L[i][1], L[i - 1][0] + a[i - 1] - (!(a[i - 1] & 1)));
  }
  for (int i = n; i >= 1; i--) {
    if (a[i] >= 2) R[i][1] = R[i + 1][1] + a[i] - (a[i] & 1);
    R[i][0] = max(R[i][1], R[i + 1][0] + a[i] - (!(a[i] & 1)));
  }
  for (int i = 1; i <= n; i++) {
    ans = max(ans, L[i][1] + R[i][0]);
    ans = max(ans, R[i][1] + L[i][0]);
  }
  cout << ans << endl;
}
