#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5;
long long lef[maxn][2], righ[maxn][2], ans, a[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    if (a[i] > 1) lef[i][1] = lef[i - 1][1] + a[i] - a[i] % 2;
    if (a[i] > 0)
      lef[i][0] = max(lef[i][1], lef[i - 1][0] + a[i] - (a[i] + 1) % 2);
  }
  for (int i = n - 2; i >= 0; i--) {
    if (a[i + 1] > 1) righ[i][1] = righ[i + 1][1] + a[i + 1] - a[i + 1] % 2;
    if (a[i + 1] > 0)
      righ[i][0] =
          max(righ[i][1], righ[i + 1][0] + a[i + 1] - (a[i + 1] + 1) % 2);
  }
  for (int i = 0; i < n; i++)
    ans = max(ans, max(lef[i][1] + righ[i][0], lef[i][0] + righ[i][1]));
  cout << ans;
}
