#include <bits/stdc++.h>
using namespace std;
inline int getOdd(int x) { return x % 2 == 1 ? x : x - 1; }
inline int getEven(int x) { return x % 2 == 0 ? x : x - 1; }
long long Left[100001], Right[100001];
long long sumOdd[100001];
int a[100001];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) scanf("%d", a + i);
  Left[0] = 0;
  sumOdd[0] = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] > 1)
      Left[i] = Left[i - 1] + getEven(a[i]);
    else
      Left[i] = 0;
    sumOdd[i] = sumOdd[i - 1] + getOdd(a[i]);
  }
  Right[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--)
    if (a[i + 1] > 1)
      Right[i] = Right[i + 1] + getEven(a[i + 1]);
    else
      Right[i] = 0;
  long long maxL = Left[0] - sumOdd[0], maxR = -(1 << 30);
  long long ans = 0;
  for (int j = 0; j < n; j++) {
    if (Left[j] - sumOdd[j] > maxL) maxL = Left[j] - sumOdd[j];
    if (Right[j] + sumOdd[j] + maxL > ans) ans = Right[j] + sumOdd[j] + maxL;
  }
  cout << ans << endl;
  return 0;
}
