#include <bits/stdc++.h>
using namespace std;
int n;
long long a[101000];
long long no[101000];
long long from[101000];
long long nor[101000];
long long fromr[101000];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i];
  }
  from[0] = 0;
  no[0] = 0;
  long long ans = 0;
  nor[n - 1] = 0;
  fromr[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    int odd = a[i] % 2;
    nor[i] = max(nor[i + 1] + a[i] - (odd + 1) % 2,
                 a[i] >= 2 ? fromr[i + 1] + a[i] - odd : 0);
    fromr[i] = a[i] >= 2 ? fromr[i + 1] + a[i] - odd : 0;
  }
  for (int i = 1; i <= n - 1; i++) {
    int odd = a[i - 1] % 2;
    no[i] = max(no[i - 1] + a[i - 1] - (odd + 1) % 2,
                a[i - 1] >= 2 ? from[i - 1] + a[i - 1] - odd : 0);
    from[i] = a[i - 1] >= 2 ? from[i - 1] + a[i - 1] - odd : 0;
  }
  for (int i = 0; i < n; i++) {
    ans = max(ans, from[i] + nor[i]);
  }
  for (int i = 0; i < n; i++) {
    ans = max(ans, no[i] + fromr[i]);
  }
  cout << ans << endl;
}
