#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
long long lp[N][2], rp[N][2];
int a[N];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    if (a[i] >= 2) lp[i][1] = lp[i - 1][1] + a[i] - (a[i] % 2 == 1);
    lp[i][0] = max(lp[i - 1][0] + a[i] - (a[i] % 2 == 0), lp[i][1]);
  }
  for (int i = n - 1; i > 0; i--) {
    if (a[i] >= 2) rp[i][1] = rp[i + 1][1] + a[i] - (a[i] % 2 == 1);
    rp[i][0] = max(rp[i + 1][0] + a[i] - (a[i] % 2 == 0), rp[i][1]);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++)
    ans = max(ans, max(lp[i][1] + rp[i + 1][0], lp[i][0] + rp[i + 1][1]));
  cout << ans << "\n";
  return 0;
}
