#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int MAX = 1e9 + 5;
long long i, j, k, n, m, RIGHT[N], LEFT[N], ans, a[N];
long long _RIGHT[N], _LEFT[N];
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n - 1; i++) scanf("%lld", &a[i]);
  for (int i = n; i >= 1; i--) {
    if (a[i] != 1) RIGHT[i] = RIGHT[i + 1] + a[i] - (a[i] & 1);
    _RIGHT[i] = max(RIGHT[i + 1], _RIGHT[i + 1]) + a[i] - (!(a[i] & 1));
  }
  for (int i = 1; i <= n; i++) {
    if (a[i - 1] != 1) LEFT[i] = LEFT[i - 1] + a[i - 1] - (a[i - 1] & 1);
    _LEFT[i] = max((a[i] != 1) * LEFT[i - 1], (_LEFT[i - 1])) + a[i - 1] -
               (!(a[i - 1] & 1));
  }
  for (int i = 1; i <= n; i++) {
    ans = max(ans, max(_LEFT[i], LEFT[i]) + RIGHT[i]);
    ans = max(ans, max(_RIGHT[i], RIGHT[i]) + LEFT[i]);
  }
  cout << ans << '\n';
  return 0;
}
