#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 101, INF = -1 * (1e+9);
long long a[MAXN], dp1[MAXN] = {}, dp2[MAXN] = {}, dp3[MAXN] = {},
                   dp4[MAXN] = {};
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", &a[i]);
  }
  long long ans = 0;
  dp1[n - 1] = 0;
  dp2[n - 1] = 0;
  for (int i = n - 2; i > -1; i--) {
    if (a[i] > 1) dp1[i] = dp1[i + 1] + a[i] - a[i] % 2;
    dp2[i] = dp2[i + 1] + a[i] + a[i] % 2 - 1;
    dp2[i] = max(dp2[i], dp1[i]);
  }
  dp3[0] = 0;
  dp4[0] = 0;
  for (int i = 1; i < n; i++) {
    if (a[i - 1] > 1) {
      dp3[i] = dp3[i - 1] + a[i - 1] - a[i - 1] % 2;
    }
    dp4[i] = dp4[i - 1] + a[i - 1] + a[i - 1] % 2 - 1;
    dp4[i] = max(dp4[i], dp3[i]);
  }
  for (int i = 0; i < n; i++) {
    ans = max(ans, dp2[i]);
    ans = max(ans, dp4[i]);
    ans = max(ans, dp1[i] + dp4[i]);
    ans = max(ans, dp2[i] + dp3[i]);
    ans = max(ans, dp2[i] + dp4[i]);
  }
  cout << ans;
}
