#include <bits/stdc++.h>
using namespace std;
long long a[100210];
long long dp[100210][4];
long long n;
int main() {
  long long i, j, k;
  cin >> n;
  for (i = 1; i < n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    if (i == 1)
      dp[i][0] = dp[i][1] = 0;
    else {
      if (a[i - 1] % 2) {
        dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) + a[i - 1];
        if (a[i - 1] == 1)
          dp[i][1] = 0;
        else
          dp[i][1] = a[i - 1] - 1 + dp[i - 1][1];
      } else {
        if (a[i - 1] == 0)
          dp[i][0] = dp[i][1] = 0;
        else {
          dp[i][0] = a[i - 1] - 1 + max(dp[i - 1][0], dp[i - 1][1]);
          dp[i][1] = a[i - 1] + dp[i - 1][1];
        }
      }
    }
  }
  for (i = n; i >= 1; i--) {
    if (i == n)
      dp[i][2] = dp[i][3] = 0;
    else {
      if (a[i] % 2) {
        dp[i][2] = max(dp[i + 1][2], dp[i + 1][3]) + a[i];
        if (a[i] == 1)
          dp[i][3] = 0;
        else
          dp[i][3] = a[i] - 1 + dp[i + 1][3];
      } else {
        if (a[i] == 0)
          dp[i][2] = dp[i][3] = 0;
        else {
          dp[i][2] = a[i] - 1 + max(dp[i + 1][2], dp[i + 1][3]);
          dp[i][3] = a[i] + dp[i + 1][3];
        }
      }
    }
  }
  long long ans = 0;
  for (i = 1; i <= n; i++) {
    ans = max(dp[i][0] + dp[i][2], ans);
    ans = max(dp[i][1] + dp[i][2], ans);
    ans = max(dp[i][1] + dp[i][3], ans);
  }
  cout << ans << endl;
  return 0;
}
