func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAX_N = (int)1e5 + 20;   long long a[MAX_N];   long long dp[2][MAX_N][2];   int n;   long long ans;   void Solve(int p) {     dp[p][0][0] = 0, dp[p][0][1] = -1;     for (int i = 1; i < n; i++) {       int bri = i - 1;       long long m = a[bri];       if (m <= 1)         dp[p][i][0] = -1;       else {         long long res = (m / 2) * 2;         if (dp[p][i - 1][0] != -1) res += dp[p][i - 1][0];         dp[p][i][0] = res;       }       if (m < 1)         dp[p][i][1] = -1;       else {         long long ret = ((m - 1) / 2) * 2 + 1;         if (max(dp[p][i - 1][0], dp[p][i - 1][1]) != -1)           ret += max(dp[p][i - 1][0], dp[p][i - 1][1]);         dp[p][i][1] = ret;       }     }   }   int main() {     cin >> n;     for (int i = 0; i < n - 1; i++) cin >> a[i];     Solve(0);     reverse(a, a + n - 1);     Solve(1);     for (int i = 0; i < n; i++) {       long long res, ted, ret;       res = ted = ret = 0;       if (dp[0][i][0] != -1 && dp[1][n - (i + 1)][1] != -1)         res = dp[0][i][0] + dp[1][n - (i + 1)][1];       if (dp[0][i][1] != -1 && dp[1][n - (i + 1)][0] != -1)         ted = dp[0][i][1] + dp[1][n - (i + 1)][0];       if (dp[0][i][0] != -1 && dp[1][n - (i + 1)][0] != -1)         ret = dp[0][i][0] + dp[1][n - (i + 1)][0];       ans = max(ans, max(ret, max(res, ted)));     }     cout << ans << endl;     return 0;   }   