#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 * 100 * 10 + 20;
long long dp1[MAXN][2], dp2[MAXN][2];
long long a[MAXN];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    dp1[i][0] = max(dp1[i - 1][0] + a[i - 1] - (1 - (a[i - 1] % 2)),
                    a[i - 1] - (1 - (a[i - 1] % 2)) + dp1[i - 1][1]);
    if ((a[i - 1] / 2) == 0)
      dp1[i][1] = 0;
    else
      dp1[i][1] = dp1[i - 1][1] + (a[i - 1] / 2) * 2;
  }
  for (int i = n - 2; i > -1; i--) {
    dp2[i][0] = max(dp2[i + 1][0] + a[i] - (1 - a[i] % 2),
                    a[i] - (1 - a[i] % 2) + dp2[i + 1][1]);
    if ((a[i] / 2) == 0)
      dp2[i][1] = 0;
    else
      dp2[i][1] = dp2[i + 1][1] + (a[i] / 2) * 2;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, dp1[i][0] + dp2[i][0]);
    ans = max(ans, dp1[i][1] + dp2[i][0]);
    ans = max(ans, dp1[i][0] + dp2[i][1]);
    ans = max(ans, dp1[i][1] + dp2[i][1]);
  }
  cout << ans << endl;
  return 0;
}
