#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b, long long m = 1000000007) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long res = power(a, b / 2, m);
  res = (res * res) % m;
  if (b & 1) res = (res * a) % m;
  return res;
}
long long modinv(long long a, long long m = 1000000007) {
  return power(a, m - 2, m);
}
long long add(long long a, long long b, long long m = 1000000007) {
  long long c = (a % m + b % m);
  if (c >= m) c -= m;
  return c;
}
long long sub(long long a, long long b, long long m = 1000000007) {
  long long c = (a % m - b % m);
  if (c < 0) c += m;
  return c;
}
long long mul(long long a, long long b, long long m = 1000000007) {
  return (a * b) % m;
}
long long odd(long long x) {
  if (x % 2 == 0) x--;
  return x;
}
long long even(long long x) {
  if (x % 2) x--;
  return x;
}
void solve() {
  long long n, ans = 0, i;
  cin >> n;
  vector<long long> a(n, 0), l(n, 0), le(n, 0), ri(n, 0), r(n, 0);
  for (i = 1; i < n; i++) cin >> a[i];
  for (i = 1; i < n; i++) {
    l[i] = max(le[i - 1], l[i - 1]) + odd(a[i]);
    le[i] = le[i - 1] + even(a[i]);
    if (a[i] == 1) le[i] = 0;
  }
  for (i = n - 2; i > 0; i--) {
    r[i] = max(ri[i + 1], r[i + 1]) + odd(a[i + 1]);
    ri[i] = ri[i + 1] + even(a[i + 1]);
    if (a[i + 1] == 1) ri[i] = 0;
  }
  for (i = 1; i < n; i++) {
    ans = max({ans, ri[i] + l[i], le[i] + r[i]});
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  for (long long i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
