#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 22;
int data[maxn];
long long zuohui[maxn];
long long zuobuhui[maxn];
long long youhui[maxn];
long long youbuhui[maxn];
int n;
long long ans;
void display() {
  cout << "zuohui ";
  for (int i = 1; i <= n; ++i) cout << zuohui[i] << ' ';
  cout << endl;
  cout << "zuobuhui ";
  for (int i = 1; i <= n; ++i) cout << zuobuhui[i] << ' ';
  cout << endl;
  cout << "youhui ";
  for (int i = 1; i <= n; ++i) cout << youhui[i] << ' ';
  cout << endl;
  cout << "youbuhui ";
  for (int i = 1; i <= n; ++i) cout << youbuhui[i] << ' ';
  cout << endl;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) scanf("%d", &data[i]);
  zuohui[1] = 0;
  for (int i = 2; i <= n; ++i) {
    if (data[i - 1] < 2)
      zuohui[i] = 0;
    else {
      int tmp;
      if (data[i - 1] & 1)
        tmp = data[i - 1] - 1;
      else
        tmp = data[i - 1];
      zuohui[i] = zuohui[i - 1] + tmp;
    }
  }
  zuobuhui[1] = 0;
  for (int i = 2; i <= n; ++i) {
    if (data[i - 1] == 0)
      zuobuhui[i] = 0;
    else {
      int tmp;
      if (data[i - 1] & 1)
        tmp = data[i - 1];
      else
        tmp = data[i - 1] - 1;
      zuobuhui[i] = max(zuohui[i - 1], zuobuhui[i - 1]) + tmp;
    }
  }
  youhui[n] = 0;
  for (int i = n - 1; i >= 1; --i) {
    if (data[i] < 2)
      youhui[i] = 0;
    else {
      int tmp;
      if (data[i] & 1)
        tmp = data[i] - 1;
      else
        tmp = data[i];
      youhui[i] = youhui[i + 1] + tmp;
    }
  }
  youbuhui[n] = 0;
  for (int i = n - 1; i >= 1; --i) {
    if (data[i] == 0)
      youbuhui[i] = 0;
    else {
      int tmp;
      if (data[i] & 1)
        tmp = data[i];
      else
        tmp = data[i] - 1;
      youbuhui[i] = max(youhui[i + 1], youbuhui[i + 1]) + tmp;
    }
  }
  ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans = max(ans, zuohui[i] + youhui[i]);
    ans = max(ans, zuohui[i] + youbuhui[i]);
    ans = max(ans, zuobuhui[i] + youhui[i]);
  }
  printf("%I64d\n", ans);
  return 0;
}
