#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
using namespace std;
bool isvowel(char c) {
  c = tolower(c);
  if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u')
    return 1;
  return 0;
}
const double eps = 0.000001;
const long double pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const long long MOD = 1e18 + 9;
const long long INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e5 + 123;
const int PRI = 555557;
const int pri = 997;
const int Magic = 2100;
int n, m, k;
int a[N];
long long ans;
pair<long long, long long> l[N], r[N];
inline void Solve() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    if (i == 1) continue;
    int val = a[i - 1];
    if (val > 1) {
      l[i].first = l[i - 1].first + (val / 2) * 2;
    }
    l[i].second = l[i - 1].second + 1 + ((val - 1) / 2) * 2;
    l[i].second = max(l[i].second, l[i].first);
  }
  for (int i = n - 1; i >= 1; i--) {
    int val = a[i];
    if (val > 1) {
      r[i].first = r[i + 1].first + (val / 2) * 2;
    }
    r[i].second = r[i + 1].second + 1 + ((val - 1) / 2) * 2;
    r[i].second = max(r[i].second, r[i].first);
  }
  for (int i = 1; i < n; i++) {
    ans = max(ans, l[i].first + r[i].second);
    ans = max(ans, r[i].first + l[i].second);
  }
  cout << ans;
}
int main() {
  int tests = 1;
  ios_base::sync_with_stdio(0), cin.tie(0);
  while (tests--) {
    Solve();
  }
  return 0;
}
