#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const int N = 100010;
long long dp1[N][2];
long long dp2[N][2];
long long a[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) scanf("%I64d", &a[i]);
  for (int i = 1; i < n; i++) {
    dp1[i][0] =
        max(dp1[i - 1][0], dp1[i - 1][1]) + ((a[i] & 1) ? a[i] : (a[i] - 1));
    if (a[i] > 1)
      dp1[i][1] = dp1[i - 1][1] + a[i] / 2 * 2;
    else
      dp1[i][1] = 0;
  }
  for (int i = n - 2; i >= 0; i--) {
    dp2[i][0] = max(dp2[i + 1][0], dp2[i + 1][1]) +
                ((a[i + 1] & 1) ? a[i + 1] : (a[i + 1] - 1));
    if (a[i + 1] > 1)
      dp2[i][1] = dp2[i + 1][1] + a[i + 1] / 2 * 2;
    else
      dp2[i][1] = 0;
  }
  long long mx = 0;
  for (int i = 0; i < n; i++) {
    long long temp = dp1[i][0] + dp2[i][1];
    long long temp2 = dp1[i][1] + dp2[i][0];
    mx = max(max(temp, temp2), mx);
  }
  printf("%I64d\n", mx);
  return 0;
}
