#include <bits/stdc++.h>
using namespace std;
int n;
int a[100010];
long long dp1[100010][2];
long long dp2[100010][2];
int main() {
  memset(a, 0, sizeof(a));
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", &a[i]);
  }
  memset(dp1, 0, sizeof(dp1));
  dp1[0][0] = dp1[0][1] = 0;
  for (int i = 1; i < n; i++) {
    if (a[i - 1] % 2 == 1) {
      dp1[i][1] = max(dp1[i - 1][1] + a[i - 1], dp1[i - 1][0] + a[i - 1]);
      if (a[i - 1] == 1)
        dp1[i][0] = 0;
      else
        dp1[i][0] = dp1[i - 1][0] + a[i - 1] - 1;
    } else {
      dp1[i][1] =
          max(dp1[i - 1][1] + a[i - 1] - 1, dp1[i - 1][0] + a[i - 1] - 1);
      dp1[i][0] = dp1[i - 1][0] + a[i - 1];
    }
  }
  memset(dp2, 0, sizeof(dp2));
  dp2[n - 1][0] = dp2[n - 1][1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    if (a[i] % 2 == 1) {
      dp2[i][1] = max(dp2[i + 1][1] + a[i], dp2[i + 1][0] + a[i]);
      if (a[i] == 1)
        dp2[i][0] = 0;
      else
        dp2[i][0] = dp2[i + 1][0] + a[i] - 1;
    } else {
      dp2[i][1] = max(dp2[i + 1][1] + a[i] - 1, dp2[i + 1][0] + a[i] - 1);
      dp2[i][0] = dp2[i + 1][0] + a[i];
    }
  }
  long long num = 0;
  for (int i = 0; i < n; i++) {
    num = max(num, max((dp1[i][1] + dp2[i][0]), (dp1[i][0] + dp2[i][1])));
  }
  cout << num;
  return 0;
}
