#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int main() {
  int N;
  while (cin >> N) {
    long long dp[2][2][2] = {0}, ans = 0;
    bool id = 0;
    for (int i = 1; i < N; ++i) {
      int n;
      cin >> n;
      id = !id;
      dp[id][1][1] = (n >= 2) * (dp[!id][1][1] + n - (n & 1));
      dp[id][1][0] = max(dp[id][1][1], dp[!id][1][0] + n - !(n & 1));
      dp[id][0][1] = max(dp[id][1][1], dp[!id][0][1] + n - !(n & 1));
      dp[id][0][0] = max(max(dp[id][0][1], dp[id][1][0]),
                         (n >= 2) * (dp[!id][0][0] + n - (n & 1)));
      ans = max(ans, dp[id][0][0]);
    }
    cout << ans << endl;
  }
  return 0;
}
