#include <bits/stdc++.h>
using namespace std;
long long a[100100];
long long lft[100010][2], rht[100010][2];
int main() {
  long long n, ans = 0;
  scanf("%lld", &n);
  n--;
  for (long long i = 1; i <= n; i++) scanf("%lld", a + i);
  n++;
  for (long long i = 2; i <= n; i++) {
    lft[i][0] = max(lft[i - 1][1], lft[i - 1][0]) +
                (a[i - 1] % 2 ? a[i - 1] : a[i - 1] - 1);
    if (a[i - 1] != 1)
      lft[i][1] = lft[i - 1][1] + (a[i - 1] % 2 ? a[i - 1] - 1 : a[i - 1]);
  }
  for (long long i = n - 1; i >= 1; i--) {
    rht[i][0] =
        max(rht[i + 1][1], rht[i + 1][0]) + (a[i] % 2 ? a[i] : a[i] - 1);
    if (a[i] != 1) rht[i][1] = rht[i + 1][1] + (a[i] % 2 ? a[i] - 1 : a[i]);
  }
  for (long long i = 1; i <= n; i++)
    ans = max(ans, max(lft[i][1] + max(rht[i][0], rht[i][1]),
                       rht[i][1] + max(lft[i][0], lft[i][1])));
  printf("%lld\n", ans);
  return 0;
}
