#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e+5 + 10;   long long b[MAXN], l[MAXN], r[MAXN], o[MAXN], dp[MAXN];   int main() {     int n;     cin >> n;     for (int i = 0; i < n - 1; i++) {       cin >> b[i];     }     for (int i = 1; i < n; i++) {       l[i] = b[i - 1] - (b[i - 1] % 2) + l[i - 1];       if (b[i - 1] == 1) l[i] = 0;     }     for (int i = n - 2; i > -1; i--) {       r[i] = b[i] - (b[i] % 2) + r[i + 1];       if (b[i] == 1) r[i] = 0;     }     for (int i = 1; i < n; i++) {       o[i] = o[i - 1] + b[i - 1] - (b[i - 1] % 2 == 0);     }     long long ans = 0, m = 0;     for (int i = 0; i < n; i++) {       m = max(m, l[i] - o[i]);       ans = max(ans, r[i] + o[i] + m);     }     cout << ans;     return 0;   }   