#include <bits/stdc++.h>
using namespace std;
long long n, ans;
long long a[100005];
long long dp1[100005][2];
long long dp2[100005][2];
int main() {
  cin >> n;
  for (int i = 1; i <= n - 1; i++) cin >> a[i];
  for (int i = 2; i <= n; i++) {
    dp1[i][0] = max(dp1[i - 1][0], dp1[i - 1][1]) +
                (a[i - 1] % 2 == 1 ? a[i - 1] : a[i - 1] - 1);
    if (a[i - 1] != 1)
      dp1[i][1] = dp1[i - 1][1] + (a[i - 1] % 2 == 0 ? a[i - 1] : a[i - 1] - 1);
  }
  for (int i = n - 1; i >= 1; i--) {
    dp2[i][0] =
        max(dp2[i + 1][0], dp2[i + 1][1]) + (a[i] % 2 == 1 ? a[i] : a[i] - 1);
    if (a[i] != 1)
      dp2[i][1] = dp2[i + 1][1] + (a[i] % 2 == 0 ? a[i] : a[i] - 1);
  }
  for (int i = 1; i <= n; i++) {
    ans = max(ans, max(dp1[i][0] + dp2[i][1], dp1[i][1] + dp2[i][0]));
  }
  cout << ans;
  return 0;
}
