func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int n;     vector<int> g;     while (cin >> n) {       int xi, xf;       xi = -1;       xf = -1;       bool init = false;       g = vector<int>(n);       for (int i = 0; i < n; i++) {         cin >> g[i];         if (init == false && g[i] == 1) {           xi = i;           xf = i;           init = true;         } else if (init == true && g[i] == 1)           xf = max(xf, i);       }       if (xi == -1 || xf == -1)         cout << 0 << endl;       else {         int ceros = 0;         for (int i = xi; i < xf;) {           if (g[i] == 0 && g[i + 1] == 0) {             i += 2;             ceros += 2;             int b = i;             for (int q = b; q <= xf; q++)               if (g[q] == 0) {                 ceros++;                 b = max(b, q);               } else                 break;             i = b + 1;           } else             i++;         }         cout << (xf - xi + 1) - ceros << endl;       }     }     return 0;   }   