#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
long long n, a[N], dp1[N], dp2[N], dp3[N], dp4[N];
long long ans;
int e(int x) {
  if (x % 2 == 0) return x;
  return x - 1;
}
int o(int x) {
  if (x % 2 == 1) {
    return x;
  }
  return x - 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  scanf("%I64d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%I64d", &a[i]);
  }
  for (int i = 2; i <= n; i++) {
    dp1[i] = dp1[i - 1] + e(a[i - 1]);
    if (a[i - 1] == 1) dp1[i] = 0;
  }
  for (int i = n - 1; i >= 1; i--) {
    dp2[i] = dp2[i + 1] + e(a[i]);
    if (a[i] == 1) dp2[i] = 0;
  }
  for (int i = 2; i <= n; i++) {
    dp3[i] = max(dp3[i - 1] + o(a[i - 1]), dp1[i]);
  }
  for (int i = n - 1; i > 0; i--) {
    dp4[i] = max(dp4[i + 1] + o(a[i]), dp2[i]);
  }
  for (int i = 1; i <= n; i++) {
    long long x, y, z, mx;
    x = dp1[i] + dp2[i];
    y = dp1[i] + dp4[i];
    z = dp3[i] + dp2[i];
    mx = max(x, y);
    mx = max(mx, z);
    ans = max(ans, mx);
  }
  cout << ans;
}
