#include <bits/stdc++.h>
using namespace std;
int n, a[1000006], odd[1000006], even[1000006];
long long lef[1000006], rig[1000006], sumOdd[1000006], best = 0, ans = 0;
void setup() {
  cin >> n;
  for (int i = 2; i <= n; i++) {
    cin >> a[i];
    if (a[i] & 1)
      odd[i] = a[i], even[i] = a[i] - 1;
    else
      odd[i] = a[i] - 1, even[i] = a[i];
    sumOdd[i] = sumOdd[i - 1] + odd[i];
  }
}
void xuly() {
  for (int i = 2; i <= n; i++)
    if (a[i] == 1)
      lef[i] = 0;
    else
      lef[i] = even[i] + lef[i - 1];
  for (int i = n - 1; i >= 1; i--)
    if (a[i + 1] == 1)
      rig[i] = 0;
    else
      rig[i] = even[i + 1] + rig[i + 1];
  for (int i = 2; i <= n; i++) {
    best = max(best, lef[i] - sumOdd[i]);
    ans = max(ans, best + sumOdd[i] + rig[i]);
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  setup();
  xuly();
  return 0;
}
