#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  long long i, j, n, m;
  cin >> n;
  long long a[n - 1];
  for (int i = 0; i < n - 1; i++) cin >> a[i];
  long long dp[n][2][2];
  memset(dp, 0, sizeof(dp));
  for (int j = 0; j < 2; j++)
    for (int k = 0; k < 2; k++) dp[1][j][k] = a[0] - 1;
  if (a[0] % 2 == 0)
    dp[1][0][0]++, dp[1][1][1]++;
  else
    dp[1][1][0]++, dp[1][0][1]++;
  long long maxi = a[0];
  for (int i = 2; i < n; i++) {
    long long t = a[i - 1];
    if (t % 2 == 0) {
      dp[i][0][0] = dp[i - 1][0][0] + t;
      dp[i][1][1] =
          max(dp[i - 1][1][1], max(dp[i - 1][0][0], dp[i - 1][0][1])) + t;
      dp[i][0][1] = max(dp[i - 1][0][0], dp[i - 1][0][1]) + t - 1;
      dp[i][1][0] = max(dp[i - 1][0][0], dp[i - 1][1][0]) + t - 1;
    } else if (t == 1) {
      dp[i][0][0] = 0;
      dp[i][1][1] = 0;
      dp[i][0][1] = max(dp[i - 1][0][0], dp[i - 1][0][1]) + 1;
      dp[i][1][0] = max(dp[i - 1][0][0], dp[i - 1][1][0]) + 1;
    } else {
      dp[i][0][0] = dp[i - 1][0][0] + t - 1;
      dp[i][1][1] =
          max(dp[i - 1][1][1], max(dp[i - 1][0][0], dp[i - 1][0][1])) + t - 1;
      dp[i][0][1] = max(dp[i - 1][0][0], dp[i - 1][0][1]) + t;
      dp[i][1][0] = max(dp[i - 1][0][0], dp[i - 1][1][0]) + t;
    }
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++) maxi = max(maxi, dp[i][j][k]);
  }
  cout << maxi;
  return 0;
}
