#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double EPS = 1e-7;
const int MAX_N = 100000;
const int KIRI = 0;
const int KANAN = 1;
int N;
long long data[MAX_N + 5];
long long memo[MAX_N + 5][5][2];
long long f(int x, int dir, bool balik) {
  if (x < 0 || x >= N) return 0;
  if (memo[x][dir][balik] != -1) return memo[x][dir][balik];
  long long &ret = memo[x][dir][balik];
  ret = 0;
  assert(dir == KIRI || dir == KANAN);
  int tmpdir = dir;
  if (dir == KIRI)
    dir = -1;
  else
    dir = 1;
  int curr = data[x];
  if (balik) {
    if (curr % 2) curr--;
    if (curr == 0)
      ret = 0;
    else
      ret = max(ret, curr + f(x + dir, tmpdir, balik));
  } else {
    ret = max(ret, max(curr - (curr % 2) + f(x + dir, tmpdir, true),
                       curr - (curr % 2 == 0) + f(x + dir, tmpdir, false)));
  }
  return ret;
}
int main() {
  cin >> N;
  N--;
  for (int(i) = 0, (_batas) = (N); (i) < (_batas); (i)++) cin >> data[i];
  long long ans = 0;
  memset(memo, -1, sizeof memo);
  for (int(i) = (0), (_batas) = (N - 1); (i) <= (_batas); (i)++) {
    if (i == 0)
      ans = max(ans, max(f(i, KANAN, true), f(i, KANAN, false)));
    else if (i == N - 1)
      ans = max(ans, max(f(i, KIRI, true), f(i, KIRI, false)));
    else {
      ans = max(ans, f(i, KANAN, true) + f(i - 1, KIRI, false));
      ans = max(ans, f(i, KANAN, false) + f(i - 1, KIRI, true));
    }
  }
  cout << ans << endl;
  return 0;
}
