#include <bits/stdc++.h>
using namespace std;
long long a[100005], b[100005];
long long la[100005], lb[100005];
long long ra[100005], rb[100005];
void sol(int n, long long *c, long long *a, long long *b) {
  int i;
  a[0] = c[0] - c[0] % 2;
  b[0] = c[0] - (c[0] + 1) % 2;
  for (i = 1; i < n; i++) {
    if (c[i] < 2)
      a[i] = 0;
    else
      a[i] = a[i - 1] + c[i] - c[i] % 2;
    b[i] =
        max(b[i - 1] + c[i] - (c[i] + 1) % 2, a[i - 1] + c[i] - (c[i] + 1) % 2);
  }
  for (i = 0; i < n; i++) a[i] = max(a[i], b[i]);
}
int main() {
  int n, i;
  long long ans;
  cin >> n;
  for (i = 0; i < n - 1; i++) cin >> a[i];
  sol(n - 1, a, la, lb);
  for (i = 0; i < n - 1; i++) b[i] = a[n - 2 - i];
  sol(n - 1, b, ra, rb);
  ans = max(la[n - 2], ra[n - 2]);
  for (i = 0; i < n - 2; i++) ans = max(ans, la[i] + ra[n - 3 - i]);
  cout << ans << endl;
  return 0;
}
