#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chkmin(T& x, T y) {
  return x > y ? x = y, true : false;
}
template <class T>
inline bool chkmax(T& x, T y) {
  return x < y ? x = y, true : false;
}
inline int read(void) {
  int x, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (x = 0; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return x * f;
}
int n, a[100005];
long long ans, f1[100005][2], f2[100005][2];
int main(void) {
  n = read();
  for (int i = 2; i <= n; ++i) a[i] = read();
  for (int i = 2; i <= n; ++i) {
    if (a[i] > 1) f1[i][1] = f1[i - 1][1] + a[i] - (a[i] & 1);
    f1[i][0] = f1[i - 1][0] + a[i] - !(a[i] & 1);
    f1[i][0] = max(f1[i][0], f1[i][1]);
  }
  for (int i = n - 1; i >= 1; --i) {
    if (a[i + 1] > 1) f2[i][1] = f2[i + 1][1] + a[i + 1] - (a[i + 1] & 1);
    f2[i][0] = f2[i + 1][0] + a[i + 1] - !(a[i + 1] & 1);
    f2[i][0] = max(f2[i][0], f2[i][1]);
  }
  for (int i = 1; i <= n; ++i)
    chkmax(ans, max(f1[i][0] + f2[i][1], f1[i][1] + f2[i][0]));
  cout << ans << endl;
  return 0;
}
