#include <bits/stdc++.h>
using namespace std;
long long int o[100001];
long long int sum[100001];
long long int dp[100001][2];
long long int dp1[100001][2];
long long int on[100001];
long long int a[100001];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%lld", &a[i]);
  }
  long long int max1 = 0;
  memset(dp, 0, sizeof dp);
  dp[0][0] = 0;
  dp[0][1] = 0;
  for (int i = 1; i < n; i++) {
    if (a[i - 1] == 1)
      dp[i][1] = 0;
    else {
      dp[i][1] = dp[i - 1][1] + a[i - 1] - (a[i - 1] & 1);
    }
    dp[i][0] = max(dp[i][1], a[i - 1] + (a[i - 1] & 1) - 1 + dp[i - 1][0]);
    max1 = max(dp[i][1], max(max1, dp[i][0]));
  }
  memset(dp1, 0, sizeof dp1);
  dp1[n - 1][0] = 0;
  dp1[n - 1][1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    if (a[i] == 1) {
      dp1[i][1] = 0;
    } else {
      dp1[i][1] = dp1[i + 1][1] + a[i] - (a[i] & 1);
    }
    dp1[i][0] = max(dp1[i][1], a[i] + (a[i] & 1) - 1 + dp1[i - 1][0]);
    max1 = max(dp1[i][1], max(max1, dp1[i][0]));
  }
  for (int i = 0; i < n; i++) {
    max1 = max(max1, max(dp[i][0] + dp1[i][1], dp1[i][0] + dp[i][1]));
  }
  cout << max1 << endl;
}
