#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:106777216")
using namespace std;
void solve();
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
long long n;
long long a[100500];
long long pref[100500], suff[100500];
void solve() {
  cin >> n;
  --n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long ans = 0, curans = 0;
  long long curans1 = 0;
  long long b1 = 0, b2 = 0;
  long long delta = 0;
  for (long long i = 0; i < n; i++) {
    if (a[i] == 0) {
      ans = max(ans, curans);
      curans = 0;
      curans1 = 0;
    }
    if (a[i] == 1) {
      ans = max(curans1, ans);
      curans = max(curans, curans1);
      curans1 = 0;
      b1 = -1;
      b2 = 0;
    }
    if (a[i] % 2) {
      curans += a[i];
      if (a[i] != 1) curans1 += a[i];
      b1++;
    }
    if (a[i] % 2 == 0 && a[i] > 0) {
      curans1 += a[i] - 1;
      curans += a[i] - 1;
      b2++;
    }
    if (delta < b2 - b1) {
      curans1 += b2 - b1 - delta;
      delta = b2 - b1;
    }
    ans = max(ans, curans);
    ans = max(ans, curans1);
    pref[i] = ans;
  }
  ans = max(ans, curans);
  curans = 0;
  curans1 = 0;
  b1 = 0;
  b2 = 0;
  suff[n] = 0;
  delta = 0;
  long long answer = ans;
  ans = 0;
  for (long long i = n - 1; i >= 0; i--) {
    if (a[i] == 0) {
      ans = max(ans, curans);
      curans = 0;
      curans1 = 0;
      continue;
    }
    if (a[i] == 1) {
      ans = max(curans1, ans);
      curans = max(curans, curans1);
      curans1 = 0;
      b1 = -1;
      b2 = 0;
    }
    if (a[i] % 2) {
      if (a[i] != 1) curans1 += a[i];
      curans += a[i];
      b1++;
    }
    if (a[i] % 2 == 0 && a[i] > 0) {
      curans1 += a[i] - 1;
      curans += a[i] - 1;
      b2++;
    }
    if (delta < b2 - b1) {
      curans1 += b2 - b1 - delta;
      delta = b2 - b1;
    }
    ans = max(ans, curans);
    ans = max(ans, curans1);
    suff[i] = ans;
  }
  ans = max(ans, curans);
  curans = 0;
  answer = max(ans, answer);
  answer = max(answer, suff[0]);
  for (long long i = 0; i < n; i++) answer = max(answer, pref[i] + suff[i + 1]);
  cout << answer;
}
