#include <bits/stdc++.h>
using namespace std;
long long a[100010];
long long dp_left[100010][2], dp_right[100010][2];
int main() {
  memset(dp_left, 0, sizeof(dp_left));
  memset(dp_right, 0, sizeof(dp_right));
  long long n;
  cin >> n;
  for (long long i = 1; i < n; i++) cin >> a[i];
  dp_left[1][0] = dp_left[1][1] = 0;
  for (long long i = 2; i <= n; i++) {
    if (a[i - 1] >= 2) dp_left[i][1] = dp_left[i - 1][1] + a[i - 1] / 2 * 2;
    if (a[i - 1] % 2)
      dp_left[i][0] =
          max(dp_left[i - 1][0] + a[i - 1], dp_left[i - 1][1] + a[i - 1]);
    else
      dp_left[i][0] = max(dp_left[i - 1][0] + a[i - 1] - 1,
                          dp_left[i - 1][1] + a[i - 1] - 1);
  }
  dp_right[n][0] = dp_right[n][1] = 0;
  for (long long i = n - 1; i >= 1; i--) {
    if (a[i] >= 2) dp_right[i][1] = dp_right[i + 1][1] + a[i] / 2 * 2;
    if (a[i] % 2)
      dp_right[i][0] =
          max(dp_right[i + 1][0] + a[i], dp_right[i + 1][1] + a[i]);
    else
      dp_right[i][0] =
          max(dp_right[i + 1][0] + a[i] - 1, dp_right[i + 1][1] + a[i] - 1);
  }
  long long Max = 0;
  for (long long i = 1; i <= n; i++) {
    Max = max(Max, dp_left[i][1] + dp_right[i][0]);
    Max = max(Max, dp_left[i][0] + dp_right[i][1]);
  }
  cout << Max << endl;
  return 0;
}
