#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  char c;
  int positive = 1;
  while (!isdigit(c = getchar()))
    if (c == '-') positive = 0;
  do x = x * 10 + c - '0';
  while (isdigit(c = getchar()));
  if (!positive) x = -x;
}
template <typename T>
inline void write(T x) {
  if (x > 9) write(x / 10);
  putchar(x % 10 + 48);
}
const int maxn = 1000010;
long long l[maxn], r[maxn];
int n;
int a[maxn];
long long ans;
long long s[maxn];
void input() {
  read(n);
  for (int i = (1), _b = (n); i < _b; i++) read(a[i]);
}
void init() {
  for (int i = (1), _b = (n); i < _b; i++)
    s[i] = s[i - 1] + a[i] - (!(a[i] % 2));
  ;
}
void solve() {
  for (int i = (n - 1), _a = (1); i >= _a; i--)
    r[i] = (a[i] == 1 ? 0 : r[i + 1] + a[i] - a[i] % 2);
  for (int i = (1), _b = (n); i < _b; i++)
    l[i] = (a[i] == 1 ? 0 : l[i - 1] + a[i] - a[i] % 2);
  long long tmp = 0;
  for (int i = (1), _b = (n); i < _b; i++) {
    tmp = max(tmp, l[i - 1] - s[i - 1]);
    ans = max(ans, tmp + r[i + 1] + s[i]);
  }
  ans = max(ans, r[1]);
}
void output() { write(ans); }
int main() {
  clock_t timestart, timeend;
  timestart = clock();
  input();
  init();
  solve();
  output();
  timeend = clock();
  return 0;
}
