#include <bits/stdc++.h>
using namespace std;
const int inf = ~0U >> 1;
const long long INF = 1000000000000000LL;
int Pow(int base, int n, int mo) {
  if (n == 0) return 1;
  if (n == 1) return base % mo;
  int tmp = Pow(base, n >> 1, mo);
  tmp = (long long)tmp * tmp % mo;
  if (n & 1) tmp = (long long)tmp * base % mo;
  return tmp;
}
long long dp[200000][3][2];
int v[200000][3], a[200000], N;
long long ans;
long long solve(int i, int j, int k) {
  if (v[i][j]) return dp[i][j][k];
  if (j == 0) {
    long long a0 = 0, a1 = 0;
    long long b0 = 0, b1 = 0;
    if (i != 1) {
      a0 += (a[i - 1] - 1) / 2 * 2;
      a1 += (a[i - 1] - 2) / 2 * 2;
      a0 += max(solve(i - 1, 2, 1), solve(i - 1, 2, 0)) + 1;
      if (a[i - 1] >= 2) a1 += solve(i - 1, 2, 1) + 2;
    }
    if (i != N) {
      b0 += (a[i] - 1) / 2 * 2;
      b1 += (a[i] - 2) / 2 * 2;
      b0 += max(solve(i + 1, 1, 1), solve(i + 1, 1, 0)) + 1;
      if (a[i] >= 2) b1 += solve(i + 1, 1, 1) + 2;
    }
    dp[i][j][1] = a1 + b1;
    dp[i][j][0] = max(a1 + b0, a0 + b1);
    ans = max(ans, max(dp[i][j][1], dp[i][j][0]));
  } else if (j == 1) {
    if (i != N) {
      dp[i][j][0] += (a[i] - 1) / 2 * 2;
      dp[i][j][1] += (a[i] - 2) / 2 * 2;
      dp[i][j][0] += max(solve(i + 1, 1, 1), solve(i + 1, 1, 0)) + 1;
      if (a[i] >= 2) dp[i][j][1] += solve(i + 1, 1, 1) + 2;
    }
  } else {
    if (i != 1) {
      dp[i][j][0] += (a[i - 1] - 1) / 2 * 2;
      dp[i][j][1] += (a[i - 1] - 2) / 2 * 2;
      dp[i][j][0] += max(solve(i - 1, 2, 1), solve(i - 1, 2, 0)) + 1;
      if (a[i - 1] >= 2) dp[i][j][1] += solve(i - 1, 2, 1) + 2;
    }
  }
  v[i][j] = 1;
  return dp[i][j][k];
}
int main() {
  scanf("%d", &N);
  for (int i = (1); i <= (N - 1); ++i) scanf("%d", &a[i]);
  for (int i = (1); i <= (N); ++i) solve(i, 0, 0);
  printf("%lld\n", ans);
  return 0;
}
