func_code_string: #include <bits/stdc++.h>   using namespace std;   int il[5];   int wyn = 0;   void printState() {}   int n;   int main() {     ios::sync_with_stdio(0);     cin >> n;     while (n--) {       int tmp;       cin >> tmp;       il[tmp]++;     }     int tmp;     if (il[1] > il[2]) {       wyn += il[2];       il[3] += il[2];       il[1] -= il[2];       il[2] = 0;       printState();       wyn += il[1] / 3 * 2;       il[3] += il[1] / 3;       il[1] = il[1] % 3;       printState();       if (il[1] == 1 && il[3] > 0) {         tmp = min(il[1], il[3]);         wyn += tmp;         il[1] -= tmp;         il[3] -= tmp;         il[4] += tmp;       } else if (il[1] == 1) {         printState();         tmp = min(1, il[4] / 2);         il[1] -= tmp;         il[4] -= 2 * tmp;         wyn += 2 * tmp;       } else if (il[1] == 2 && il[4] > 0) {         wyn += il[1];         il[4] -= il[1];         il[3] += il[1] * 2;         il[1] = 0;       } else if (il[1] == 2) {         tmp = min(il[1], il[3]);         wyn += tmp;         il[1] -= tmp;         il[3] -= tmp;       }       printState();     } else {       wyn += il[1];       il[3] += il[1];       il[2] -= il[1];       il[1] = 0;       printState();       wyn += il[2] / 3 * 2;       il[3] += il[2] / 3 * 2;       il[2] = il[2] % 3;       printState();       if (il[2] == 1 && il[4] > 0) {         il[2] = 0;         il[4] -= 1;         il[3] += 2;         wyn += 1;       } else if (il[2] == 1 && il[3] >= 2) {         il[3] -= 2;         il[2] -= 1;         il[4] += 2;         wyn += 2;       } else if (il[2] == 2) {         il[4] += 1;         il[2] -= 2;         wyn += 2;       }       printState();     }     cout << (il[2] + il[1] > 0 ? -1 : wyn) <<   n ;     return 0;   }   