#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
long long n, a[N], l[N], r[N], dis[N], ans = -1e18, L[N], R[N];
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) scanf("%lld", &a[i]);
  for (int i = 2; i <= n; i++) {
    if (a[i - 1] <= 1)
      l[i] = 0;
    else
      l[i] = l[i - 1] + a[i - 1] - (a[i - 1] % 2);
  }
  for (int i = n - 1; i >= 1; i--) {
    if (a[i] <= 1)
      r[i] = 0;
    else
      r[i] = r[i + 1] + a[i] - (a[i] % 2);
  }
  for (int i = 2; i <= n; i++) {
    if (a[i - 1] > 0) {
      dis[i] = dis[i - 1] + a[i - 1] - (a[i - 1] % 2 == 0);
    }
  }
  L[0] = R[n + 1] = -1e18;
  for (int i = 1; i <= n; i++) {
    L[i] = max(L[i - 1], l[i] - dis[i]);
  }
  for (int i = n; i >= 1; i--) {
    R[i] = max(R[i + 1], r[i] + dis[i]);
  }
  for (int i = 1; i <= n; i++) ans = max(ans, L[i] + R[i]);
  printf("%lld\n", ans);
  return 0;
}
