func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int kl[5] = {0}, n, ans = 0, x;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> x;       kl[x]++;     }     x = min(kl[1], kl[2]);     ans += x;     kl[1] -= x;     kl[2] -= x;     kl[3] += x;     if (kl[1] != 0) {       ans += kl[1] / 3 * 2;       kl[3] += kl[1] / 3;       kl[1] %= 3;       if (kl[1] == 1) {         if (kl[3] != 0) {           ans++;           kl[3]--;           kl[4]++;           kl[1] = 0;         } else if (kl[4] >= 2) {           ans += 2;           kl[3] += 3;           kl[1] = 0;           kl[4] -= 2;         }       }       if (kl[1] == 2) {         if (kl[3] >= 2) {           ans += 2;           kl[1] = 0;           kl[3] -= 2;           kl[4] += 2;         } else {           ans++;           kl[1] = 0;           kl[2]++;         }       }     }     if (kl[2] != 0) {       ans += kl[2] / 3 * 2;       kl[3] += kl[2] / 3 * 2;       kl[2] %= 3;       if (kl[2] == 2) {         ans += 2;         kl[2] = 0;       }       if (kl[2] == 1) {         if (kl[4] != 0) {           ans += 1;           kl[2]--;         } else if (kl[3] >= 2) {           ans += 2;           kl[2] = 0;         }       }     }     if (kl[2] == 0 && kl[1] == 0)       cout << ans << endl;     else       cout <<  -1  << endl;     cin >> n;     return 0;   }   