func_code_string: #include <bits/stdc++.h>   using namespace std;   int cnt[10];   int main() {     int n;     while (scanf( %d , &n) != EOF) {       int sum = 0;       memset(cnt, 0, sizeof(cnt));       for (int i = 0; i < n; i++) {         int j;         scanf( %d , &j);         cnt[j]++;         sum += j;       }       int ans = -1;       for (int i = 0; i <= n; i++)         if (4 * i <= sum && (sum - 4 * i) % 3 == 0 &&             (sum - 4 * i) / 3 <= n - i) {           int j = (sum - 4 * i) / 3;           int cost = min(max(cnt[4] - i, 0), j);           int p = cnt[1] + cnt[2] + cnt[3] + cnt[4];           for (int k = 1; k <= 4 && p > i + j; k++) {             cost += min(p - i - j, cnt[k]) * k;             p -= min(p - i - j, cnt[k]);           }           if (cost < ans || ans == -1) ans = cost;         }       printf( %d n , ans);     }     return 0;   }   