#include <bits/stdc++.h>
const double PI = acos(-1);
using namespace std;
const int MAX = 100 * 1000 + 10;
int n;
int A[MAX];
long long goLeftAndDontReturn[MAX];
long long goRightAndDontReturn[MAX];
long long goLeftAndReturn[MAX];
long long goRightAndReturn[MAX];
int main() {
  scanf("%d", &n);
  for (int i = (2); i <= (n); i++) scanf("%d", A + i);
  for (int i = 2; i <= n; i++) {
    int x = A[i];
    if (x == 1) continue;
    goLeftAndReturn[i] = goLeftAndReturn[i - 1] + x - (x & 1);
  }
  for (int i = n - 1; i >= 1; i--) {
    int x = A[i + 1];
    if (x == 1) continue;
    goRightAndReturn[i] = goRightAndReturn[i + 1] + x - (x & 1);
  }
  for (int i = 2; i <= n; i++) {
    int x = A[i];
    goLeftAndDontReturn[i] = goLeftAndDontReturn[i - 1] + x - (x % 2 == 0);
    goLeftAndDontReturn[i] = max(goLeftAndDontReturn[i], goLeftAndReturn[i]);
  }
  for (int i = n - 1; i >= 1; i--) {
    int x = A[i + 1];
    goRightAndDontReturn[i] = goRightAndDontReturn[i + 1] + x - (x % 2 == 0);
    goRightAndDontReturn[i] = max(goRightAndDontReturn[i], goRightAndReturn[i]);
  }
  long long ans = 0;
  for (int i = (1); i <= (n); i++) {
    ans = max(ans, goLeftAndReturn[i] + goRightAndDontReturn[i]);
    ans = max(ans, goRightAndReturn[i] + goLeftAndDontReturn[i]);
  }
  cout << ans << endl;
  return 0;
}
