#include <bits/stdc++.h>
using namespace std;
int n, a[100010];
long long L[100010], R[100010], s[100010], res;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 2; i <= n; ++i)
    if (a[i - 1] == 1)
      L[i] = 0;
    else
      L[i] = L[i - 1] + a[i - 1] - a[i - 1] % 2;
  for (int i = n - 1; i >= 1; --i)
    if (a[i] == 1)
      R[i] = 0;
    else
      R[i] = R[i + 1] + a[i] - a[i] % 2;
  for (int i = 2; i <= n; ++i) s[i] = s[i - 1] + a[i - 1] - (1 - a[i - 1] % 2);
  long long val = 0;
  for (int i = 2; i <= n; ++i) {
    val = max(val, L[i] - s[i]);
    res = max(res, R[i] + s[i] + val);
  }
  printf("%I64d", res);
}
