#include <bits/stdc++.h>
using namespace std;
static const int INF = 500000000;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
int n;
int a[100005];
long long int L[2][100005], R[2][100005];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  for (int i = 0; i < n - 1; ++i) {
    if (a[i] == 1)
      L[0][i + 1] = 0;
    else
      L[0][i + 1] = (a[i] / 2 * 2) + L[0][i];
    L[1][i + 1] = max(L[0][i + 1], (a[i] % 2 ? a[i] : a[i] - 1) + L[1][i]);
  }
  for (int i = n - 2; i >= 0; --i) {
    if (a[i] == 1)
      R[0][i] = 0;
    else
      R[0][i] = (a[i] / 2 * 2) + R[0][i + 1];
    R[1][i] = max(R[0][i], (a[i] % 2 ? a[i] : a[i] - 1) + R[1][i + 1]);
  }
  long long int ans = 0;
  for (int i = 0; i < n; ++i)
    ans = max(ans, max(L[0][i] + R[1][i], L[1][i] + R[0][i]));
  cout << ans << endl;
  return 0;
}
