#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
long long l[N][2], r[N][2];
long long a[N];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) scanf("%I64d", a + i);
  for (int i = 2; i <= n; i++) {
    if (a[i - 1] > 1)
      l[i][0] = ((a[i - 1] & 1) ? a[i - 1] - 1 : a[i - 1]) + l[i - 1][0];
    if (a[i - 1] & 1)
      l[i][1] = max(l[i - 1][0] + a[i - 1] - 1, l[i - 1][1] + a[i - 1]);
    else
      l[i][1] = max(l[i - 1][0] + a[i - 1], l[i - 1][1] + a[i - 1] - 1);
  }
  for (int i = n - 1; i > 0; i--) {
    if (a[i] > 1) r[i][0] = ((a[i] & 1) ? a[i] - 1 : a[i]) + r[i + 1][0];
    if (a[i] & 1)
      r[i][1] = max(r[i + 1][0] + a[i] - 1, r[i + 1][1] + a[i]);
    else
      r[i][1] = max(r[i + 1][0] + a[i], r[i + 1][1] + a[i] - 1);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    ans = max(ans, max(l[i][0] + r[i][1], l[i][1] + r[i][0]));
  cout << ans << endl;
  return 0;
}
