#include <bits/stdc++.h>
using namespace std;
long long judge(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
int main() {
  long long n;
  cin >> n;
  vector<long long> jump_chances;
  for (int i = 0; i < n - 1; i++) {
    long long jump_chance;
    cin >> jump_chance;
    jump_chances.push_back(jump_chance);
  }
  vector<long long> right_jump(n, 0), left_jump(n, 0), max_left(n, 0),
      max_right(n, 0);
  for (int i = n - 2; i >= 0; i--) {
    if (jump_chances[i] > 1)
      right_jump[i] =
          right_jump[i + 1] + (jump_chances[i] - jump_chances[i] % 2);
    else
      right_jump[i] = 0;
    if (jump_chances[i] % 2 == 1)
      max_right[i] = max_right[i + 1] + jump_chances[i];
    else
      max_right[i] =
          judge(max_right[i + 1] + jump_chances[i] - 1, right_jump[0]);
  }
  for (int i = 1; i < n; i++) {
    if (jump_chances[i - 1] > 1)
      left_jump[i] =
          left_jump[i - 1] + jump_chances[i - 1] - jump_chances[i - 1] % 2;
    else
      left_jump[i] = 0;
    if (jump_chances[i - 1] % 2 == 1)
      max_left[i] = (max_left[i - 1] + jump_chances[i - 1]);
    else
      max_left[i] =
          judge(max_left[i - 1] + jump_chances[i - 1] - 1, left_jump[i]);
  }
  long long max_jump = 0;
  for (int i = 0; i < n; i++) {
    max_jump = judge(max_jump, judge(max_left[i] + right_jump[i],
                                     max_right[i] + left_jump[i]));
  }
  cout << max_jump;
  return 0;
}
