#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 * 1000 + 10;
long long int dp1[MAXN];
long long int dp2[MAXN];
long long int dp3[MAXN];
int n;
int a[MAXN];
long long int fans = 0;
void solve() {
  for (int i = n; i; i--) {
    dp1[i] = (a[i] / 2) * 2;
    if (a[i] > 1) dp1[i] += dp1[i + 1];
  }
  for (int i = 1; i <= n; i++) {
    dp2[i] = (a[i] / 2) * 2;
    if (a[i] > 1) dp2[i] += dp2[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    dp3[i] = dp2[i];
    int x = a[i];
    if (x % 2 == 0) x--;
    if (x) dp3[i] = max(dp3[i], x + dp3[i - 1]);
    fans = max(fans, dp3[i] + dp1[i + 1]);
  }
}
int main() {
  cin >> n;
  n--;
  for (int i = 0; i < n; i++) cin >> a[i + 1];
  solve();
  reverse(a, a + n);
  solve();
  cout << fans << endl;
  return 0;
}
