#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N];
long long dp[N][2][2];
int main() {
  int n;
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i < n; i++) cin >> a[i];
  for (int i = n - 1; i > 0; i--) {
    if (a[i] % 2) {
      dp[i][1][1] = a[i] + max(dp[i + 1][1][1], dp[i + 1][1][0]);
      dp[i][1][0] = a[i] - 1 + dp[i + 1][1][0];
      if (a[i] == 1) dp[i][1][0] = 0;
    } else {
      dp[i][1][1] = a[i] - 1 + max(dp[i + 1][1][0], dp[i + 1][1][1]);
      dp[i][1][0] = a[i] + dp[i + 1][1][0];
    }
  }
  for (int i = 2; i <= n; i++) {
    if (a[i - 1] % 2) {
      dp[i][0][1] = a[i - 1] + max(dp[i - 1][0][1], dp[i - 1][0][0]);
      dp[i][0][0] = a[i - 1] - 1 + dp[i - 1][0][0];
      if (a[i - 1] == 1) dp[i][0][0] = 0;
    } else {
      dp[i][0][1] = a[i - 1] - 1 + max(dp[i - 1][0][0], dp[i - 1][0][1]);
      dp[i][0][0] = a[i - 1] + dp[i - 1][0][0];
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans,
              max(dp[i][0][0] + dp[i][1][0],
                  max(dp[i][0][1] + dp[i][1][0], dp[i][0][0] + dp[i][1][1])));
  }
  cout << ans << endl;
  return 0;
}
