#include <bits/stdc++.h>
using namespace std;
long long a[1000001], f[1000001][10], g[1000010][10];
long long n;
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) cin >> a[i];
  f[1][0] = f[1][1] = 0;
  for (int i = 2; i <= n; i++) {
    f[i][0] = max(f[i - 1][0], f[i - 1][1]) + a[i - 1] - !(a[i - 1] % 2);
    if (a[i - 1] > 1) {
      f[i][1] = f[i - 1][1] + a[i - 1] - (a[i - 1] % 2);
    }
  }
  g[n][0] = g[n][1] = 0;
  for (int i = n - 1; i >= 1; i--) {
    g[i][0] = max(g[i + 1][1], g[i + 1][0]) + a[i] - !(a[i] % 2);
    if (a[i] > 1) {
      g[i][1] = g[i + 1][1] + a[i] - (a[i] % 2);
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, f[i][0] + g[i][1]);
    ans = max(ans, f[i][1] + g[i][0]);
    ans = max(ans, f[i][1] + g[i][1]);
  }
  cout << ans;
  return 0;
}
