#include <bits/stdc++.h>
using namespace std;
long long v[100003], st[100003], dr[100003], unu[100003];
int main() {
  long long n, i, dr_max = 0, st_max = 0, ans = 0;
  cin >> n;
  for (i = 1; i < n; i++) cin >> v[i];
  for (i = 2; i <= n; i++)
    if (v[i - 1] > 1) st[i] = st[i - 1] + (v[i - 1] / 2) * 2;
  for (i = n - 1; i >= 1; i--)
    if (v[i] > 1) dr[i] = dr[i + 1] + (v[i] / 2) * 2;
  for (i = 2; i <= n; i++) unu[i] = unu[i - 1] + ((v[i - 1] + 1) / 2) * 2 - 1;
  for (i = 1; i <= n; i++) {
    dr_max = dr[i] + unu[i];
    st_max = max(st_max, st[i] - unu[i]);
    ans = max(ans, st_max + dr_max);
  }
  cout << ans;
  return 0;
}
