#include <bits/stdc++.h>
using namespace std;
int num[100010];
long long dp[2][100010];
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    long long ans = 0, tmp;
    for (int i = 1; i < n; ++i) scanf("%d", &num[i]);
    dp[0][0] = 0;
    for (int i = 1; i < n; ++i)
      if (num[i] > 1)
        dp[0][i] = dp[0][i - 1] + (num[i] - (num[i] & 1));
      else
        dp[0][i] = 0;
    dp[1][n - 1] = 0;
    for (int i = n - 2; i >= 0; --i)
      if (num[i + 1] > 1)
        dp[1][i] = dp[1][i + 1] + (num[i + 1] - (num[i + 1] & 1));
      else
        dp[1][i] = 0;
    tmp = 0;
    for (int i = 0; i < n; ++i) {
      ans = max(ans, tmp + dp[1][i]);
      tmp = max(tmp + (num[i + 1] - (~num[i + 1] & 1)), dp[0][i + 1]);
    }
    cout << ans << endl;
  }
  return 0;
}
