#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  register char c = getchar();
  x = 0;
  for (; c < '0' || c > '9'; c = getchar())
    ;
  for (; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + c - '0';
}
int main() {
  int n, x;
  long long t, a = 0, b = 0, c = 0, z = 0;
  read(n);
  while (--n) {
    read(x);
    if (x > 1) {
      if (x & 1) {
        c = max(a, c) + x - 1;
        a = max(a, b) + x;
        b += x - 1;
      } else {
        c = max(a, c) + x;
        a = max(a, b) + x - 1;
        b += x;
      }
    } else {
      if (x & 1)
        a = max(a, b) + x;
      else
        a = max(a, b) + x - 1;
      b = c = 0;
    }
    z = max(max(z, a), max(b, c));
  }
  cout << z;
}
