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