#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 9;
int n;
long long a[N], l[N], r[N];
void home() {}
void enter() {
  scanf("%d", &n);
  for (int i = (0); i <= (n + 1); ++i) a[i] = l[i] = r[i] = 0;
  for (int i = (1); i <= (n - 1); ++i) scanf("%d", &a[i]);
}
void solve() {
  for (int i = (1); i <= (n); ++i)
    if (a[i - 1] > 1) l[i] = l[i - 1] + a[i - 1] / 2 * 2;
  for (int i = (n); i >= (1); --i)
    if (a[i] > 1) r[i] = r[i + 1] + ((a[i] >> 1) << 1);
  for (int i = (1); i <= (n - 1); ++i) {
    if (~a[i] & 1) --a[i];
    a[i] += a[i - 1];
  }
  long long ma = 0, res = 0;
  for (int i = (n); i >= (1); --i)
    res =
        ((res) > ((ma = ((ma) > (r[i] + a[i - 1]) ? (ma) : (r[i] + a[i - 1]))) +
                  l[i] - a[i - 1])
             ? (res)
             : ((ma = ((ma) > (r[i] + a[i - 1]) ? (ma) : (r[i] + a[i - 1]))) +
                l[i] - a[i - 1]));
  printf("%I64d\n", res);
}
int main() {
  home();
  enter();
  solve();
}
