func_code_string: #include <bits/stdc++.h>   using namespace std;   void swapll(long long *a, long long *b) {     long long tmp = *a;     *a = *b;     *b = tmp;   }   void swapc(char *a, char *b) {     char tmp = *a;     *a = *b;     *b = tmp;   }   void solve() {     long long n;     cin >> n;     vector<long long> v(n, 0);     for (long long i = 0; i < n; i++) cin >> v[i];     ;     long long count = 0;     long long idx = -1;     for (long long i = 0; i < n; i++) {       if (v[i] == 1 && idx == -1) {         count++;         idx = i;       } else if (v[i] == 1 && i - idx == 1) {         count++;         idx = i;       } else if (v[i] == 1 && i - idx != 1) {         count += 2;         idx = i;       }     }     cout << count << endl;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     solve();     return 0;   }   