#include <bits/stdc++.h>
using namespace std;
long long dp[100000][3][2];
int n;
int adj[100000][2];
long long solve(int p, int d, int b) {
  long long& res = dp[p][d][b];
  if (res != -1) return res;
  res = 0;
  if (d == 2) {
    long long dirback = 0, dirnoback = 0, esqback = 0, esqnoback = 0, t;
    t = adj[p][1] - (adj[p][1] % 2 == 0);
    if (adj[p][1]) dirnoback = solve(p + 1, 1, 0) + t;
    t = adj[p][0] - (adj[p][0] % 2 == 0);
    if (adj[p][0]) esqnoback = solve(p - 1, 0, 0) + t;
    t = adj[p][1] - (adj[p][1] % 2 != 0);
    if (adj[p][1] > 1) dirback = solve(p + 1, 1, 1) + t;
    t = adj[p][0] - (adj[p][0] % 2 != 0);
    if (adj[p][0] > 1) esqback = solve(p - 1, 0, 1) + t;
    res = max(res, dirnoback + esqback);
    res = max(res, esqnoback + dirback);
  } else {
    if (b) {
      long long back = 0, t;
      t = adj[p][d] - (adj[p][d] % 2 != 0);
      if (adj[p][d] > 1) back = solve(p + (d == 0 ? -1 : 1), d, 1) + t;
      res = back;
    } else {
      long long back = 0, noback = 0, t;
      t = adj[p][d] - (adj[p][d] % 2 == 0);
      if (adj[p][d]) noback = solve(p + (d == 0 ? -1 : 1), d, 0) + t;
      t = adj[p][d] - (adj[p][d] % 2 != 0);
      if (adj[p][d] > 1) back = solve(p + (d == 0 ? -1 : 1), d, 1) + t;
      res = max(back, noback);
    }
  }
  return res;
}
int main() {
  memset(dp, -1, sizeof dp);
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int a;
    scanf("%d", &a);
    adj[i][1] = a;
    adj[i + 1][0] = a;
  }
  long long res = 0;
  for (int i = 0; i < n; ++i) res = max(res, solve(i, 2, 0));
  cout << res << endl;
  return 0;
}
