#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::map;
using std::pair;
using std::stable_sort;
using std::string;
using std::vector;
using namespace std;
long long mas[100010];
long long lefts[100010];
long long rights[100010];
long long center[100010];
int main() {
  int n;
  cin >> n;
  long long z = 0;
  long long z2 = 0;
  for (long long i = 0; i < n - 1; i++) {
    cin >> mas[i];
    z2 += mas[i];
    if (mas[i] % 2 == 0) z2--;
    center[i + 1] = z2;
    z += mas[i] - mas[i] % 2;
    if (mas[i] == 1) z = 0;
    lefts[i + 1] = z;
  }
  n--;
  z = 0;
  for (int i = n; i >= 0; i--) {
    z += mas[i] - mas[i] % 2;
    if (mas[i] == 1) z = 0;
    rights[i] = z;
  }
  int max2 = 0;
  long long maxim2[100010];
  for (int i = 0; i <= n; i++) {
    if (lefts[i] - center[i] > max2) max2 = lefts[i] - center[i];
    maxim2[i] = max2;
  }
  long long maxim = 0;
  for (int j = 0; j <= n; j++) {
    long long temp = maxim2[j] + rights[j] + center[j];
    if (temp > maxim) maxim = temp;
  }
  cout << maxim;
  return 0;
}
