#include <bits/stdc++.h>
using namespace std;
long long n, a[200000], f[200000][4][4];
int main() {
  int DEBUG = 1;
  if (!DEBUG) {
    freopen("bridges.inp", "r", stdin);
    freopen("bridges.out", "w", stdout);
  }
  cin >> n;
  for (int i = 1; i < n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 4; j++)
      for (int k = 0; k < 4; k++) f[i][j][k] = -1e18 - 7;
  for (int i = 1; i <= n; i++) f[i][0][0] = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] == 0) continue;
    if (a[i] == 1) {
      f[i + 1][0][1] = max(f[i + 1][0][1], f[i][0][1] + 1);
      f[i + 1][1][1] = max(f[i + 1][1][1], max(f[i][0][0], f[i][1][1]) + 1);
      f[i + 1][2][1] = max(f[i + 1][2][1], max(f[i][1][0], f[i][2][1]) + 1);
      continue;
    }
    f[i + 1][0][0] = max(f[i + 1][0][0], f[i][0][0] + (a[i] / 2) * 2);
    f[i + 1][0][1] =
        max(f[i + 1][0][1], f[i][0][1] + ((a[i] + 1) / 2) * 2 - 1LL);
    f[i + 1][1][0] =
        max(f[i + 1][1][0], max(f[i][1][0], f[i][0][1]) + (a[i] / 2) * 2);
    f[i + 1][1][1] = max(f[i + 1][1][1], max(f[i][1][1], f[i][0][0]) +
                                             ((a[i] + 1) / 2) * 2 - 1LL);
    f[i + 1][2][0] =
        max(f[i + 1][2][0], max(f[i][2][0], f[i][1][1]) + (a[i] / 2) * 2);
    f[i + 1][2][1] = max(f[i + 1][2][1], max(f[i][2][1], f[i][1][0]) +
                                             ((a[i] + 1) / 2) * 2 - 1LL);
  }
  long long res = 0;
  for (int i = 1; i <= n; i++)
    res = max(res, max(f[i][0][0], max(f[i][1][1], f[i][2][0])));
  cout << res;
}
