#include <bits/stdc++.h>
using namespace std;
long long int dp[100001], l[100001], r[100001], a[1000001];
int main() {
  long long int i, j, n, ans = -1;
  cin >> n;
  for (i = 1; i < n; i++) cin >> a[i];
  l[0] = 0;
  for (i = 1; i < n; i++) {
    if (a[i] == 1)
      l[i] = 0;
    else
      l[i] = l[i - 1] + a[i] / 2 * 2;
  }
  r[n - 1] = 0;
  for (i = n - 2; i >= 0; i--) {
    if (a[i + 1] == 1)
      r[i] = 0;
    else
      r[i] = r[i + 1] + a[i + 1] / 2 * 2;
  }
  dp[0] = 0;
  for (i = 1; i < n; i++) dp[i] = max(dp[i - 1] + (a[i] - 1) / 2 * 2 + 1, l[i]);
  for (i = 0; i < n; i++) ans = max(ans, dp[i] + r[i]);
  cout << ans;
  return 0;
}
