#include <bits/stdc++.h>
using namespace std;
int i, j, n, m;
long long int p[111101], l[111101], r[111101], sum;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  n--;
  for (i = 1; i <= n; i++) {
    cin >> p[i];
  }
  long long int now = 0;
  for (i = 1; i <= n; i++) {
    if (p[i] & 1) {
      l[i] = l[i - 1] + p[i];
      if (p[i] > 1)
        now += p[i] - 1;
      else
        now = 0;
    } else {
      l[i] = l[i - 1] + p[i] - 1;
      now += p[i];
    }
    if (now > l[i]) l[i] = now;
  }
  long long int ans;
  now = 0;
  for (i = n; i; i--) {
    if (p[i] & 1) {
      if (p[i] > 1)
        now += p[i] - 1;
      else
        now = 0;
    } else {
      now += p[i];
    }
    r[i] = now;
  }
  ans = now;
  for (i = 0; i <= n; i++) {
    if (l[i] + r[i + 1] > ans) ans = l[i] + r[i + 1];
  }
  cout << ans;
  return 0;
}
