#include <bits/stdc++.h>
using namespace std;
const double eps(1e-8);
long long n;
long long v[110000];
long long f[110000][2][2];
int main() {
  scanf("%I64d", &n);
  for (long long i = (2); i <= (n); ++i) scanf("%I64d", &v[i]);
  f[1][0][0] = f[1][0][1] = 0;
  for (long long i = (2); i <= (n); ++i) {
    if (v[i] >= 2)
      f[i][0][1] = f[i - 1][0][1] + 2 * (v[i] / 2);
    else
      f[i][0][1] = 0;
    f[i][0][0] = max(f[i][0][1], f[i - 1][0][0] + 1 + ((v[i] - 1) / 2) * 2);
  }
  f[n][1][0] = f[n][1][1] = 0;
  for (long long i = (n - 1); i >= (1); --i) {
    if (v[i + 1] >= 2)
      f[i][1][1] = f[i + 1][1][1] + 2 * (v[i + 1] / 2);
    else
      f[i][1][1] = 0;
    f[i][1][0] = max(f[i][1][1], f[i - 1][1][0] + 1 + 2 * ((v[i + 1] - 1) / 2));
  }
  long long ans = 0;
  for (long long i = (1); i <= (n); ++i)
    ans = max(max(ans, f[i][0][1] + f[i][1][0]),
              max(f[i][0][0] + f[i][1][1], f[i][0][1] + f[i][1][1]));
  printf("%I64d\n", ans);
}
