#include <bits/stdc++.h>
using namespace std;
int a[100004];
long long f[100004][3];
int main() {
  int n;
  int i, j;
  long long ans = 0LL;
  scanf("%d", &n);
  for (i = 1; i < n; i++) scanf("%d", &a[i]);
  f[0][0] = 0;
  f[0][1] = f[0][2] = -1LL << 60;
  for (i = 1; i < n; i++) {
    f[i][0] = f[0][0];
    f[i][1] = f[0][1];
    f[i][2] = f[0][2];
    if (a[i] == 1) {
      f[i][1] = max(f[i][1], max(f[i - 1][0] + 1, f[i - 1][1] + 1));
    } else if (a[i]) {
      if (a[i] % 2) {
        a[i]--;
        j = 1;
      } else
        j = 0;
      f[i][0] = max(f[i][0], f[i - 1][0] + a[i]);
      f[i][2] = max(f[i][2], f[i - 1][1] + a[i]);
      f[i][2] = max(f[i][2], f[i - 1][2] + a[i]);
      if (j)
        a[i]++;
      else
        a[i]--;
      f[i][1] = max(f[i][1], f[i - 1][0] + a[i]);
      f[i][1] = max(f[i][1], f[i - 1][1] + a[i]);
    }
    ans = max(ans, max(f[i][0], max(f[i][1], f[i][2])));
  }
  cout << ans << endl;
  return 0;
}
