#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n;
int a[maxn];
long long dp[maxn][3][3];
int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) scanf("%d", &a[i]);
  for (int i = 1; i < n; i++) {
    if (a[i - 1] == 0) continue;
    int b = a[i - 1];
    if (b % 2 == 0) b--;
    dp[i][0][0] = dp[i - 1][0][0] + b;
    b = a[i - 1];
    if (b <= 1) continue;
    if (b % 2 == 1) b--;
    dp[i][0][1] = dp[i - 1][0][1] + b;
    dp[i][0][0] = max(dp[i][0][0], dp[i][0][1]);
  }
  for (int i = n - 2; i >= 0; i--) {
    if (a[i] == 0) continue;
    int b = a[i];
    if (b % 2 == 0) b--;
    dp[i][1][0] = dp[i + 1][1][0] + b;
    b = a[i];
    if (b <= 1) continue;
    if (b % 2 == 1) b--;
    dp[i][1][1] = dp[i + 1][1][1] + b;
    dp[i][1][0] = max(dp[i][1][0], dp[i][1][1]);
  }
  long long sol = 0;
  sol = dp[0][1][0];
  sol = max(sol, dp[n - 1][0][0]);
  for (int i = 1; i < n - 1; i++) {
    long long c1 = dp[i][1][0];
    if (a[i - 1] > 1) {
      int add = a[i - 1];
      if (add % 2 == 1) add--;
      c1 += dp[i - 1][0][1] + add;
    }
    sol = max(sol, c1);
    long long c2 = dp[i][0][0];
    if (a[i] > 1) {
      int add = a[i];
      if (add % 2 == 1) add--;
      c2 += dp[i + 1][1][1] + add;
    }
    sol = max(sol, c2);
  }
  printf("%lld\n", sol);
  return 0;
}
