#include <bits/stdc++.h>
#pragma GCC optimize("-O2")
using namespace std;
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\t";
  err(++it, args...);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& c, pair<T1, T2>& v) {
  c << "(" << v.first << "," << v.second << ")";
  return c;
}
template <template <class...> class TT, class... T>
ostream& operator<<(ostream& out, TT<T...>& c) {
  out << "{ ";
  for (auto& x : c) out << x << " ";
  out << "}";
  return out;
}
const int LIM = 1e5 + 5, MOD = 1e9 + 7;
int t, n, m, k, x, y, w;
int a[LIM];
long long f[LIM], b[LIM];
long long bb[LIM], ff[LIM];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; ++i) cin >> a[i];
  long long ans = 0;
  for (int i = 1; i < n; ++i) {
    b[i] = (a[i - 1] > 1 ? b[i - 1] + (((a[i - 1]) >> 1) << 1) : 0);
    bb[i] = max(b[i], 1 + (((a[i - 1] - 1) >> 1) << 1) + bb[i - 1]);
    ans = max(ans, bb[i]);
  }
  for (int i = n - 2; i >= 0; --i) {
    f[i] = (a[i] > 1 ? f[i + 1] + (((a[i]) >> 1) << 1) : 0);
    ff[i] = max(f[i], 1 + (((a[i] - 1) >> 1) << 1) + ff[i + 1]);
    ans = max({ans, ff[i] + b[i], bb[i] + f[i]});
  }
  cout << ans << '\n';
  return 0;
}
