#include <bits/stdc++.h>
using namespace std;
void boost() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  boost();
  long long n, i, j;
  cin >> n;
  long long a[n];
  for (i = 1; i < n; i++) cin >> a[i];
  long long pre[n + 1], suf[n + 1];
  pre[1] = 0;
  suf[n] = 0;
  for (i = 2; i < n + 1; i++) {
    if (a[i - 1] < 2)
      pre[i] = 0;
    else
      pre[i] = pre[i - 1] + (a[i - 1] / 2) * 2;
  }
  for (i = n - 1; i >= 1; i--) {
    if (a[i] < 2)
      suf[i] = 0;
    else
      suf[i] = suf[i + 1] + (a[i] / 2) * 2;
  }
  long long bet[n + 1];
  bet[1] = 0;
  for (i = 2; i < n + 1; i++) {
    bet[i] = bet[i - 1];
    if (a[i - 1] % 2)
      bet[i] += a[i - 1];
    else
      bet[i] += a[i - 1] - 1;
  }
  long long temp, ans = 0, mx;
  ans = pre[1] + suf[1];
  mx = pre[1] - bet[1];
  for (i = 2; i < n + 1; i++) {
    temp = suf[i] + bet[i];
    mx = max(mx, pre[i] - bet[i]);
    ans = max(ans, temp + mx);
  }
  cout << ans;
}
