#include <bits/stdc++.h>
using namespace std;
long long a[100005], dp[100005][2][2], n;
long long update(long long index, long long dir, long long back) {
  if (dp[index][dir][back] != -1) return dp[index][dir][back];
  long long mx = 0;
  if (dir == 0) {
    if (index == 0)
      mx = 0;
    else {
      if (back == 0) {
        mx = 2 * ((a[index - 1] - 1) / 2) + 1 +
             max(update(index - 1, 0, 0), update(index - 1, 0, 1));
      } else if (a[index - 1] > 1) {
        mx = 2 * (a[index - 1] / 2) + update(index - 1, 0, 1);
      }
    }
  } else {
    if (index == n - 1)
      mx = 0;
    else {
      if (back == 0) {
        mx = 2 * ((a[index] - 1) / 2) + 1 +
             max(update(index + 1, 1, 0), update(index + 1, 1, 1));
      } else if (a[index] > 1) {
        mx = 2 * (a[index] / 2) + update(index + 1, 1, 1);
      }
    }
  }
  return dp[index][dir][back] = mx;
}
int main() {
  cin >> n;
  memset(dp, -1, sizeof(dp));
  for (long long i = 0; i < n - 1; i++) cin >> a[i];
  long long result = 0;
  for (long long i = 0; i < n; i++)
    result = max(max(result, update(i, 1, 1) + update(i, 0, 1)),
                 max(update(i, 0, 0) + update(i, 1, 1),
                     update(i, 1, 0) + update(i, 0, 1)));
  cout << result << endl;
  return 0;
}
