#include <bits/stdc++.h>
using namespace std;
const int MAXN = 111 * 1000;
int n;
long long a[MAXN], odd[MAXN], dpr[MAXN], dpl[MAXN], e2r[MAXN], e2l[MAXN];
void print(string name, long long* a, int len) {
  return;
  cerr << name << ":";
  for (register int i = (0); i < (int)(n); ++i) cerr << " " << a[i];
  cout << endl;
}
int main() {
  cin >> n;
  for (register int i = (1); i < (int)(n); ++i) {
    cin >> a[i];
    if (a[i] % 2)
      odd[i] = a[i];
    else
      odd[i] = a[i] - 1;
  }
  print("a", a, n);
  print("odd", odd, n);
  for (int i = n; i >= 1; i--) {
    if (a[i] / 2)
      e2r[i] = e2r[i + 1] + (a[i] / 2) * 2;
    else
      e2r[i] = 0;
    dpr[i] = max(dpr[i + 1] + odd[i], e2r[i]);
  }
  print("e2r", e2r, n);
  print("dpr", dpr, n);
  for (register int i = (1); i < (int)(n); ++i) {
    if (a[i] / 2)
      e2l[i] = e2l[i - 1] + (a[i] / 2) * 2;
    else
      e2l[i] = 0;
    dpl[i] = max(dpl[i - 1] + odd[i], e2l[i]);
  }
  print("e2l", e2l, n);
  print("dpl", dpl, n);
  long long res = 0;
  for (register int i = (1); i < (int)(n); ++i)
    res = max(max(e2l[i - 1] + dpr[i], dpl[i - 1] + e2r[i]), res);
  cout << res << endl;
  return 0;
}
