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