#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
long long dp[N][2][2];
int a[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) scanf("%d", &a[i]);
  for (int i = 2; i <= n; i++) {
    dp[i][0][0] =
        max(dp[i - 1][0][0], dp[i - 1][0][1]) + a[i - 1] - (a[i - 1] & 1 ^ 1);
    if (a[i - 1] == 1)
      dp[i][0][1] = 0;
    else
      dp[i][0][1] = dp[i - 1][0][1] + a[i - 1] - (a[i - 1] & 1);
  }
  for (int i = n - 1; i >= 1; i--) {
    dp[i][1][0] = max(dp[i + 1][1][0], dp[i + 1][1][1]) + a[i] - (a[i] & 1 ^ 1);
    if (a[i] == 1)
      dp[i][1][1] = 0;
    else
      dp[i][1][1] = dp[i + 1][1][1] + a[i] - (a[i] & 1);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++)
        if (!j && !k)
          continue;
        else
          ans = max(ans, dp[i][0][j] + dp[i][1][k]);
  printf("%I64d\n", ans);
  return 0;
}
