#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void setmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline void setmin(T &a, T b) {
  if (b < a) a = b;
}
long long r1[100005], r2[100005], l1[100005], l2[100005], ans[100005];
int b[100005];
int dte(int n) { return n & 1 ? n : n - 1; }
int dto(int n) { return n & 1 ? n - 1 : n; }
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
  }
  r1[n - 1] = r2[n - 1] = l1[0] = l2[0] = 0;
  for (int i = n - 2; i >= 0; i--) {
    r1[i] = max((long long)b[i], dte(b[i]) + r1[i + 1]);
    setmax(r1[i], b[i] + r2[i + 1]);
    if (b[i] >= 2) {
      r2[i] = dto(b[i]) + r2[i + 1];
    } else
      r2[i] = 0;
  }
  for (int i = 1; i < n; i++) {
    l1[i] = max((long long)b[i - 1], dte(b[i - 1]) + l1[i - 1]);
    setmax(l1[i], b[i - 1] + l2[i - 1]);
    if (b[i - 1] >= 2) {
      l2[i] = dto(b[i - 1]) + l2[i - 1];
    } else
      l2[i] = 0;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    setmax(ans, l2[i] + r1[i]);
    setmax(ans, r2[i] + l1[i]);
  }
  cout << ans << endl;
  return 0;
}
