#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, d[maxn];
long long l[maxn][2], r[maxn][2], ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) scanf("%d", &d[i]);
  l[0][0] = l[0][1] = 0;
  for (int i = 1; i < n; i++) {
    l[i][1] = d[i] < 2 ? 0 : l[i - 1][1] + d[i] / 2 * 2;
    if (d[i] & 1)
      l[i][0] = l[i - 1][0] + d[i];
    else
      l[i][0] = max(l[i][1], l[i - 1][0] + d[i] - 1);
  }
  r[n - 1][0] = r[n - 1][1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    r[i][1] = d[i + 1] < 2 ? 0 : r[i + 1][1] + d[i + 1] / 2 * 2;
    if (d[i + 1] & 1)
      r[i][0] = r[i + 1][0] + d[i + 1];
    else
      r[i][0] = max(r[i][1], r[i + 1][0] + d[i + 1] - 1);
  }
  ans = (long long)0;
  for (int i = 0; i < n; i++)
    ans = max(
        ans,
        max(r[i][0], max(l[i][0], max(l[i][1] + r[i][0], r[i][1] + l[i][0]))));
  printf("%I64d\n", ans);
  return 0;
}
