#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
long long l[100005];
long long r[100005];
long long data[100005];
long long sum_odd[100005];
int n;
int main() {
  while (scanf("%d", &n) == 1) {
    memset(sum_odd, 0, sizeof sum_odd);
    memset(l, 0, sizeof l);
    memset(r, 0, sizeof r);
    for (int i = 1; i <= n - 1; i++) {
      scanf("%I64d", &data[i]);
    }
    sum_odd[1] = 0;
    for (int i = 2; i <= n; i++) {
      if (data[i - 1] % 2 == 1) {
        sum_odd[i] = sum_odd[i - 1] + data[i - 1];
      } else {
        sum_odd[i] = sum_odd[i - 1] + data[i - 1] - 1;
      }
    }
    l[1] = 0;
    for (int i = 2; i <= n; i++) {
      if (data[i - 1] == 1)
        l[i] = 0;
      else {
        if (data[i - 1] % 2 == 1) {
          l[i] = l[i - 1] + data[i - 1] - 1;
        } else {
          l[i] = l[i - 1] + data[i - 1];
        }
      }
    }
    r[n] = 0;
    for (int i = n - 1; i >= 1; i--) {
      if (data[i] == 1)
        r[i] = 0;
      else {
        if (data[i] % 2 == 1) {
          r[i] = r[i + 1] + data[i] - 1;
        } else {
          r[i] = r[i + 1] + data[i];
        }
      }
    }
    long long ans = 0;
    long long tmp = 0;
    for (int i = 1; i <= n; i++) {
      if (tmp < l[i] - sum_odd[i]) {
        tmp = l[i] - sum_odd[i];
      }
      ans = max(ans, r[i] + sum_odd[i] + tmp);
    }
    cout << ans << endl;
  }
}
