#include <bits/stdc++.h>
using namespace std;
long long mas[111111], n, Left[111111], Right[111111], maxL, sumOdd, ans;
long long odd(long long x) {
  if (x & 1) return x;
  return x - 1;
}
long long even(long long x) {
  if (x & 1) return x - 1;
  return x;
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; ++i) cin >> mas[i];
  for (int i = 1; i < n; ++i)
    if (1 == mas[i - 1])
      Left[i] = 0;
    else
      Left[i] += Left[i - 1] + even(mas[i - 1]);
  for (int i = n - 2; i >= 0; --i)
    if (1 == mas[i])
      Right[i] = 0;
    else
      Right[i] += Right[i + 1] + even(mas[i]);
  for (int i = 0; i < n; ++i) {
    if (Left[i] - sumOdd > maxL) maxL = Left[i] - sumOdd;
    if (Right[i] + sumOdd + maxL > ans) ans = Right[i] + sumOdd + maxL;
    sumOdd += odd(mas[i]);
  }
  cout << ans << endl;
  return 0;
}
