#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
template <typename T>
void read(T &x) {
  char c = getchar();
  int f = 0;
  while (c < '0' || c > '9') f |= (c == '-'), c = getchar();
  for (x = 0; c >= '0' && c <= '9'; c = getchar())
    x = (x << 3) + (x << 1) + c - '0';
  if (f) x = -x;
}
int n;
int s[N];
long long A[N], B[N], C[N], D[N];
void calc() {
  memset(A, 0, sizeof A);
  memset(B, 0, sizeof B);
  for (int i = 2; i <= n; ++i) {
    A[i] = A[i - 1];
    if (s[i] % 2 == 1)
      A[i] += s[i];
    else
      A[i] += s[i] - 1;
    if (s[i] % 2 == 0) {
      A[i] = max(A[i], B[i - 1] + s[i]);
    }
    if (s[i] == 1)
      B[i] = 0;
    else {
      B[i] = B[i - 1];
      if (s[i] % 2 == 0)
        B[i] += s[i];
      else
        B[i] += s[i] - 1;
    }
  }
}
int main() {
  read(n);
  for (int i = 2; i <= n; ++i) read(s[i]);
  calc();
  memcpy(C, A, sizeof A);
  memcpy(D, B, sizeof B);
  for (int i = 1; i < n; ++i) s[i] = s[i + 1];
  s[n] = 0;
  reverse(s + 1, s + n + 1);
  calc();
  reverse(A + 1, A + n + 1);
  reverse(B + 1, B + n + 1);
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans = max(ans, A[i] + D[i]);
    ans = max(ans, B[i] + C[i]);
  }
  cout << ans << endl;
  return 0;
}
