#include <bits/stdc++.h>
using namespace std;
const int M = 100000 + 10;
long long int a[M];
long long int leftnoback[M];
long long int leftback[M];
long long int rightnoback[M];
long long int rightback[M];
int main() {
  time_t t_start, t_end;
  t_start = clock();
  int n;
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n; i++) {
    int x = (a[i] - 1) / 2 * 2;
    leftnoback[i] = x + 1 + max(leftnoback[i - 1], leftback[i - 1]);
    if (a[i] == 1) {
      leftback[i] = 0;
    } else {
      int x = a[i] / 2 * 2;
      leftback[i] = x + leftback[i - 1];
    }
  }
  for (int i = n - 2; i >= 0; i--) {
    int x = (a[i + 1] - 1) / 2 * 2;
    rightnoback[i] = x + 1 + max(rightnoback[i + 1], rightback[i + 1]);
    if (a[i + 1] == 1) {
      rightback[i] = 0;
    } else {
      int x = a[i + 1] / 2 * 2;
      rightback[i] = x + rightback[i + 1];
    }
  }
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, leftnoback[i]);
    ans = max(ans, leftback[i] + max(rightback[i], rightnoback[i]));
    ans = max(ans, rightnoback[i]);
    ans = max(ans, rightback[i] + max(leftnoback[i], leftback[i]));
  }
  cout << ans << endl;
  t_end = clock();
  return 0;
}
