#include <bits/stdc++.h>
using namespace std;
long long A[100005], L[100005], R[100005], L2[100005], R2[100005], n, i, mx;
int main() {
  cin >> n;
  for (i = 1; i < n; i++) cin >> A[i];
  for (i = 2; i <= n; i++)
    if (A[i - 1] != 1) L[i] = L[i - 1] + A[i - 1] - (A[i - 1] & 1);
  for (i = n - 1; i; i--)
    if (A[i] != 1) R[i] = R[i + 1] + A[i] - (A[i] & 1);
  for (i = 2; i <= n; i++)
    L2[i] = max(L[i], L2[i - 1] + A[i - 1] - !(A[i - 1] & 1) +
                          (!(A[i - 1] & 1) && L[i - 1] == L2[i - 1]));
  for (i = n - 1; i; i--)
    R2[i] = max(R[i], R2[i + 1] + A[i] - !(A[i] & 1) +
                          (!(A[i] & 1) && R[i + 1] == R2[i + 1]));
  for (i = 1; i <= n; i++) mx = max(mx, max(L[i] + R2[i], R[i] + L2[i]));
  cout << mx;
  return 0;
}
