#include <bits/stdc++.h>
using namespace std;
long long cnt[100010], a[100010], b[100010], c[100010], d[100010];
int n;
int main() {
  cin >> n;
  for (int i = (1); i <= (n - 1); i++) scanf("%d", &cnt[i]);
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  memset(c, 0, sizeof(c));
  memset(d, 0, sizeof(d));
  for (int i = (2); i <= (n); i++) {
    if (cnt[i - 1]) {
      if ((cnt[i - 1] % 2) == 0) {
        a[i] = cnt[i - 1] - 1 + max(b[i - 1], a[i - 1]);
        b[i] = cnt[i - 1] + b[i - 1];
      } else {
        a[i] = cnt[i - 1] + max(a[i - 1], b[i - 1]);
        if (cnt[i - 1] > 1) b[i] = cnt[i - 1] - 1 + b[i - 1];
      }
    }
  }
  for (int i = (n - 1); i >= (1); i--) {
    if (cnt[i]) {
      if ((cnt[i] % 2) == 0) {
        c[i] = cnt[i] - 1 + max(c[i + 1], d[i + 1]);
        d[i] = cnt[i] + d[i + 1];
      } else {
        c[i] = cnt[i] + max(c[i + 1], d[i + 1]);
        if (cnt[i] > 1) d[i] = cnt[i] - 1 + d[i + 1];
      }
    }
  }
  long long res = 0;
  for (int i = (1); i <= (n); i++) {
    res = max(res, max(a[i] + d[i], b[i] + d[i]));
    res = max(res, b[i] + c[i]);
  }
  cout << res << endl;
  return 0;
}
