#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
long long n, a[N], l[N], l_back[N], r[N], r_back[N], help[N], help_back[N];
long long go(long long l) { return (l & 1 ? l : l - 1); }
long long come(long long l) { return (l & 1 ? l - 1 : l); }
void build() {
  for (int i = n - 2; i >= 0; i--) {
    long long len = a[i];
    help[i] = go(len) + help[i + 1];
    help_back[i] = (len == 1 ? 0 : come(len) + help_back[i + 1]);
    help[i] = max(help[i], help_back[i]);
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) cin >> a[i];
  build();
  for (int i = 0; i < n; i++) r[i] = help[i], r_back[i] = help_back[i];
  memset(help, 0, sizeof help);
  memset(help_back, 0, sizeof help_back);
  reverse(a, a + n - 1);
  build();
  for (int i = 0; i < n; i++)
    l[i] = help[n - i - 1], l_back[i] = l_back[n - i - 1];
  long long ans = 0;
  for (int i = 0; i < n; i++)
    ans = max(ans, max(l_back[i] + r[i], r_back[i] + l[i]));
  cout << ans;
  return 0;
}
