#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = 3.1415926535897932384626433832795;
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T abs(T x) {
  return x < 0 ? -x : x;
}
const int nmax = 100100;
int n;
int a[nmax];
long long l[nmax][2], r[nmax][2];
long long calc() {
  memset(l, 0, sizeof l);
  for (int i = 1; i < n; i++) {
    long long len = a[i];
    l[i][0] = l[i - 1][0] + len - 1 + len % 2;
    l[i][0] = max(l[i][0], l[i - 1][1] + len - len % 2);
    if (len == 1)
      l[i][1] = 0;
    else
      l[i][1] = l[i - 1][1] + len - len % 2;
  }
  return 0;
}
long long get() {
  memset(r, 0, sizeof r);
  calc();
  memcpy(r, l, sizeof l);
  reverse(a + 1, a + n);
  calc();
  long long res = 0;
  for (int i = 1; i < n; i++) {
    long long now =
        max(l[i][1], l[i][0]) + max(r[n - i - 1][0], r[n - i - 1][1]);
    res = max(res, now);
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 0; i < (int)(n - 1); i++) scanf("%d", &a[i + 1]);
  long long res = get();
  cout << res << endl;
  return 0;
}
