#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e5 + 13;
long long n, a[maxN], dp0[maxN][5], dp1[maxN][5], ans;
int32_t main() {
  cin >> n;
  for (long long i = 0; i < n - 1; i++) cin >> a[i];
  dp0[0][0] = dp0[0][1] = 0;
  for (long long i = 1; i < n; i++) {
    dp0[i][0] = ((a[i - 1] % 2) ? a[i - 1] : a[i - 1] - 1) +
                max(dp0[i - 1][0], dp0[i - 1][1]);
    if (a[i - 1] != 1)
      dp0[i][1] = ((a[i - 1] % 2) ? a[i - 1] - 1 : a[i - 1]) + dp0[i - 1][1];
  }
  dp1[n - 1][0] = dp1[n - 1][1] = 0;
  for (long long i = n - 2; i >= 0; i--) {
    dp1[i][0] =
        ((a[i] % 2) ? a[i] : a[i] - 1) + max(dp1[i + 1][0], dp1[i + 1][1]);
    if (a[i] != 1) dp1[i][1] = ((a[i] % 2) ? a[i] - 1 : a[i]) + dp1[i + 1][1];
  }
  for (long long i = 0; i < n; i++) {
    long long res1 = max(dp0[i][0], dp0[i][1]) + max(dp1[i][0], dp1[i][1]);
    ans = max(ans, res1);
  }
  cout << ans << endl;
}
