#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T Max(T a, T b) {
  if (a > b)
    return a;
  else
    return b;
}
template <class T>
inline T Min(T a, T b) {
  if (a < b)
    return a;
  else
    return b;
}
template <class T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <class T>
inline T TripleMax(T a, T b, T c) {
  return Max(Max(a, b), c);
}
template <class T>
inline T TripleMin(T a, T b, T c) {
  return Min(Min(a, b), c);
}
const long double pi = M_PI;
const long double e = M_E;
const long double sqrt2 = M_SQRT2;
const long long llinfinity = 9223372036854775807LL;
const long long llminusinfinity = -9223372036854775808LL;
const int intinfinity = 2147483647;
const int intminusinfinity = -2147483648;
const long long maxn = 100005;
long long n;
long long data[maxn];
long long leftnum[maxn], rightnum[maxn];
long long ret;
long long numodd[maxn];
long long largest;
inline long long odd(long long num) {
  if (num % 2 == 0) {
    return num - 1;
  } else {
    return num;
  }
}
inline long long even(long long num) {
  if (num % 2 == 0) {
    return num;
  } else {
    return num - 1;
  }
}
int main(int argc, const char* argv[]) {
  cin >> n;
  memset(data, 0, sizeof(data));
  memset(leftnum, 0, sizeof(leftnum));
  memset(rightnum, 0, sizeof(rightnum));
  memset(numodd, 0, sizeof(numodd));
  for (int i = 1; i < n; i++) {
    cin >> data[i];
  }
  for (int i = 2; i < n + 1; i++) {
    if (data[i - 1] == 1) {
      leftnum[i] = 0;
    } else {
      leftnum[i] = leftnum[i - 1] + even(data[i - 1]);
    }
  }
  for (int i = n - 1; i >= 1; i--) {
    if (data[i] == 1) {
      rightnum[i] = 0;
    } else {
      rightnum[i] = rightnum[i + 1] + even(data[i]);
    }
  }
  numodd[1] = 0;
  for (int i = 2; i < n + 1; i++) {
    numodd[i] = numodd[i - 1] + odd(data[i - 1]);
  }
  largest = llminusinfinity;
  ret = llminusinfinity;
  for (int i = 1; i < n + 1; i++) {
    long long tmp1;
    long long tmp2;
    tmp1 = rightnum[i] + numodd[i];
    tmp2 = leftnum[i] - numodd[i];
    if (tmp2 > largest) {
      largest = tmp2;
    }
    tmp1 += largest;
    if (tmp1 > ret) {
      ret = tmp1;
    }
  }
  cout << ret << endl;
  return 0;
}
