#include <bits/stdc++.h>
using namespace std;
bool deb = false;
const int N = 100011;
long long int a[N], Left[N], Right[N], odd[N];
long long int m[N];
int main() {
  long long int i, j, n;
  scanf("%lld", &n);
  for (i = 1; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  Left[1] = 0;
  for (i = 2; i < n + 1; ++i) {
    if (a[i - 1] == 1)
      Left[i] = 0;
    else {
      int add;
      if (a[i - 1] & 1)
        add = a[i - 1] - 1;
      else
        add = a[i - 1];
      Left[i] = Left[i - 1] + add;
    }
  }
  Right[n] = 0;
  for (i = n - 1; i > 0; --i) {
    if (a[i] == 1)
      Right[i] = 0;
    else {
      int add;
      if (a[i] & 1)
        add = a[i] - 1;
      else
        add = a[i];
      Right[i] = Right[i + 1] + add;
    }
  }
  odd[1] = 0;
  for (i = 2; i < n + 1; ++i) {
    int add;
    if (a[i - 1] & 1)
      add = a[i - 1];
    else
      add = a[i - 1] - 1;
    odd[i] = odd[i - 1] + add;
  }
  long long int mx = -1000000007 * 10000LL;
  for (i = 1; i < n + 1; ++i) {
    mx = max(mx, Left[i] - odd[i]);
    m[i] = mx;
  }
  mx = -1000000007 * 10000LL;
  for (i = 1; i < n + 1; ++i) {
    mx = max(mx, m[i] + Right[i] + odd[i]);
  }
  printf("%lld\n", mx);
  return 0;
}
