#include <bits/stdc++.h>
#pragma comment(linker, "/stack:102400000,102400000")
using namespace std;
const int N = 100005;
const int M = 35;
const long long INF = (1LL << 60);
const int MOD = 1000000007;
const double Pi = acos(-1.0);
int lowbit(int x) { return x & (-x); }
template <class T>
inline T f_min(T a, T b) {
  return a < b ? a : b;
}
template <class T>
inline T f_max(T a, T b) {
  return a > b ? a : b;
}
template <class T>
inline T f_abs(T a) {
  return a > 0 ? a : -a;
}
template <class T>
inline T f_gcd(T a, T b) {
  return b == 0 ? a : f_gcd(b, a % b);
}
template <class T>
inline T f_Lcm(T a, T b) {
  return a / f_gcd(a, b) * b;
}
template <class T>
inline void f_swap(T &a, T &b) {
  T t = a;
  a = b;
  b = t;
}
bool is_digit(char a) {
  if (a >= '0' && a <= '9') return true;
  return false;
}
bool is_lowch(char a) {
  if (a >= 'a' && a <= 'z') return true;
  return false;
}
bool is_upch(char a) {
  if (a >= 'A' && a <= 'Z') return true;
  return false;
}
long long a[N], dp[N][2], x[N][2];
int main() {
  int n;
  while (cin >> n) {
    for (int i = 1; i < n; ++i) cin >> a[i];
    memset(dp, 0, sizeof(dp));
    for (int i = 2; i <= n; ++i) {
      if (a[i - 1] == 1)
        dp[i][0] = 0;
      else
        dp[i][0] = dp[i - 1][0] + a[i - 1] / 2 * 2;
      long long temp = a[i - 1];
      if (a[i - 1] % 2 == 0) temp = a[i - 1] - 1;
      dp[i][1] = f_max(dp[i - 1][0], dp[i - 1][1]) + temp;
    }
    memset(x, 0, sizeof(x));
    for (int i = n - 1; i > 0; --i) {
      if (a[i] == 1)
        x[i][0] = 0;
      else
        x[i][0] = x[i + 1][0] + a[i] / 2 * 2;
      long long temp = a[i];
      if (a[i] % 2 == 0) temp--;
      x[i][1] = f_max(x[i + 1][0], x[i + 1][1]) + temp;
    }
    long long res = 0;
    for (int i = 1; i <= n; ++i)
      res = f_max(res, f_max(dp[i][0] + f_max(x[i][0], x[i][1]),
                             x[i][0] + f_max(dp[i][0], dp[i][1])));
    cout << res << endl;
  }
  return 0;
}
