#include <bits/stdc++.h>
using namespace std;
int a[100006];
long long l[100006], r[100006], odd[100006], p[100006];
int n;
long long res, m_i;
int main() {
  cin >> n;
  for (int i = 1; i < n; ++i) cin >> a[i];
  for (int i = 1; i < n; ++i) {
    odd[i] = odd[i - 1] + a[i];
    if (a[i] % 2 == 0) --odd[i];
  }
  for (int i = 1; i < n; ++i)
    if (a[i] < 2)
      l[i] = 0;
    else
      l[i] = l[i - 1] + a[i] / 2 * 2;
  for (int i = n - 2; i >= 0; --i)
    if (a[i + 1] < 2)
      r[i] = 0;
    else
      r[i] = r[i + 1] + a[i + 1] / 2 * 2;
  m_i = l[0] - odd[0];
  for (int i = 0; i < n; ++i) {
    m_i = max(m_i, l[i] - odd[i]);
    res = max(res, r[i] + odd[i] + m_i);
  }
  cout << res;
  return 0;
}
