#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n, ans, val[N], dpl1[N], dpl2[N], dpr1[N], dpr2[N];
signed main() {
  scanf("%lld", &n);
  for (int i = 1; i < n; ++i) {
    long long x;
    scanf("%lld", &x);
    if (x > 1) dpl2[i] = (dpl2[i - 1] + x) - ((dpl2[i - 1] + x) & 1);
    if (x & 1)
      dpl1[i] = dpl1[i - 1] + x;
    else
      dpl1[i] = max(dpl2[i], dpl1[i - 1] + x - 1);
    val[i] = x;
  }
  for (int i = n - 2; i; --i) {
    if (val[i] > 1)
      dpr2[i] = (dpr2[i + 1] + val[i + 1]) - ((dpr2[i - 1] + val[i + 1]) & 1);
    if (val[i] & 1)
      dpr1[i] = dpr1[i + 1] + val[i + 1];
    else
      dpr1[i] = max(dpr2[i], dpr1[i + 1] + val[i + 1] - 1);
  }
  for (int i = 0; i < n; ++i)
    ans = max(ans, max(dpl1[i] + dpr2[i], dpl1[i] + dpr1[i]));
  return printf("%lld\n", ans), 0;
}
