#include <bits/stdc++.h>
using namespace std;
long long n, a[100005], dp[100005][4], ans;
signed main() {
  cin >> n;
  for (long long i = 2; i <= n; cin >> a[i++])
    ;
  for (long long i = 2; i <= n; i++) {
    dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) + a[i] - !(a[i] & 1);
    if (bool(a[i] ^ 1)) dp[i][1] = dp[i - 1][1] + a[i] - (a[i] & 1);
  }
  for (long long i = n - 1; i; i--) {
    dp[i][2] = max(dp[i + 1][2], dp[i + 1][3]) + a[i + 1] - !(a[i + 1] & 1);
    if (bool(a[i + 1] ^ 1)) dp[i][3] = dp[i + 1][3] + a[i + 1] - (a[i + 1] & 1);
  }
  for (long long i = 1; i <= n; i++) {
    ans = max(ans, max(dp[i][0] + dp[i][3], dp[i][1] + dp[i][2]));
  }
  cout << ans;
  return 0;
}
