#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long INF = 1e18;
const long long N = 1e5 + 100;
long long n;
long long a[N], dp_right[N], dp_left[N], full_right[N], full_left[N];
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (long long i = 1; i <= n; i++) {
    if (a[i] != 1)
      full_left[i] = full_left[i - 1] + (a[i] % 2 == 0 ? a[i] : a[i] - 1);
    dp_left[i] = dp_left[i - 1] + (a[i] % 2 == 0 ? a[i] - 1 : a[i]);
    dp_left[i] = max(dp_left[i], full_left[i]);
  }
  for (long long i = n; i >= 1; i--) {
    if (a[i] != 1)
      full_right[i] = full_right[i + 1] + (a[i] % 2 == 0 ? a[i] : a[i] - 1);
    dp_right[i] = dp_right[i + 1] + (a[i] % 2 == 0 ? a[i] - 1 : a[i]);
    dp_right[i] = max(dp_right[i], full_right[i]);
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    long long x = max({dp_right[i], dp_left[i], dp_left[i] + full_right[i + 1],
                       full_left[i] + dp_right[i + 1]});
    ans = max(ans, x);
  }
  cout << ans << '\n';
}
