#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MaxN = (int)1e6 + 5;
const int MOD = (int)1e9 + 7;
int n;
int s[MaxN];
int cnt[MaxN];
int ans;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 1; i <= n; i++){
cin >> s[i];
cnt[s[i]]++;
}
sort(s + 1, s + 1 + n, greater<int>());
for(int i = 1; i <= n; i++){
if(s[i] == 4 && cnt[4] >= 1){
++ans;
cnt[4]--;
}
else if(s[i] == 3 && cnt[1] >= 1 && cnt[3] >= 1){
++ans;
cnt[3]--;
cnt[1]--;
}
else if(s[i] == 3 && cnt[1] == 0 && cnt[3] >= 1){
++ans;
cnt[3]--;
}
else if(s[i] == 2 && cnt[2] >= 2){
++ans;
cnt[2] -= 2;
}
else if((s[i] == 2 && cnt[1] >= 2 && cnt[2] >= 1)){
++ans;
cnt[2]--;
cnt[1] -= 2;
}
else if(s[i] == 2 && cnt[1] >= 1 && cnt[2] >= 1){
++ans;
--cnt[2]; --cnt[1];
}
else if(s[i] == 2 && cnt[2] >= 1 && cnt[1] == 0){
++ans;
cnt[2]--;
}
else if(s[i] == 1 && cnt[1] >= 1){
int b = 1;
while(b <= 4 && cnt[1] > 0){
--cnt[1];
++b;
}
++ans;
}
}
cout << ans;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIGludCBsb25nIGxvbmcKCmNvbnN0IGludCBNYXhOID0gKGludCkxZTYgKyA1Owpjb25zdCBpbnQgTU9EID0gKGludCkxZTkgKyA3OwoKaW50IG47CmludCBzW01heE5dOwppbnQgY250W01heE5dOwppbnQgYW5zOwoKc2lnbmVkIG1haW4oKXsKICAgIGlvczo6c3luY193aXRoX3N0ZGlvKDApOwogICAgY2luLnRpZSgwKTsKICAgIGNpbiA+PiBuOwogICAgZm9yKGludCBpID0gMTsgaSA8PSBuOyBpKyspewogICAgICAgIGNpbiA+PiBzW2ldOwogICAgICAgIGNudFtzW2ldXSsrOwogICAgfQogICAgc29ydChzICsgMSwgcyArIDEgKyBuLCBncmVhdGVyPGludD4oKSk7CiAgICBmb3IoaW50IGkgPSAxOyBpIDw9IG47IGkrKyl7CiAgICAgICAgaWYoc1tpXSA9PSA0ICYmIGNudFs0XSA+PSAxKXsKICAgICAgICAgICAgKythbnM7CiAgICAgICAgICAgIGNudFs0XS0tOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmKHNbaV0gPT0gMyAmJiBjbnRbMV0gPj0gMSAmJiBjbnRbM10gPj0gMSl7CiAgICAgICAgICAgICsrYW5zOwogICAgICAgICAgICBjbnRbM10tLTsKICAgICAgICAgICAgY250WzFdLS07CiAgICAgICAgfQogICAgICAgIGVsc2UgaWYoc1tpXSA9PSAzICYmIGNudFsxXSA9PSAwICYmIGNudFszXSA+PSAxKXsKICAgICAgICAgICAgKythbnM7CiAgICAgICAgICAgIGNudFszXS0tOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmKHNbaV0gPT0gMiAmJiBjbnRbMl0gPj0gMil7CiAgICAgICAgICAgICsrYW5zOwogICAgICAgICAgICBjbnRbMl0gLT0gMjsKICAgICAgICB9CiAgICAgICAgZWxzZSBpZigoc1tpXSA9PSAyICYmIGNudFsxXSA+PSAyICYmIGNudFsyXSA+PSAxKSl7CiAgICAgICAgICAgICsrYW5zOwogICAgICAgICAgICBjbnRbMl0tLTsKICAgICAgICAgICAgY250WzFdIC09IDI7CiAgICAgICAgfQogICAgICAgIGVsc2UgaWYoc1tpXSA9PSAyICYmIGNudFsxXSA+PSAxICYmIGNudFsyXSA+PSAxKXsKICAgICAgICAgICAgKythbnM7CiAgICAgICAgICAgIC0tY250WzJdOyAtLWNudFsxXTsKICAgICAgICB9CiAgICAgICAgZWxzZSBpZihzW2ldID09IDIgJiYgY250WzJdID49IDEgJiYgY250WzFdID09IDApewogICAgICAgICAgICArK2FuczsKICAgICAgICAgICAgY250WzJdLS07CiAgICAgICAgfQogICAgICAgIGVsc2UgaWYoc1tpXSA9PSAxICYmIGNudFsxXSA+PSAxKXsKICAgICAgICAgICAgaW50IGIgPSAxOwogICAgICAgICAgICB3aGlsZShiIDw9IDQgJiYgY250WzFdID4gMCl7CiAgICAgICAgICAgICAgICAtLWNudFsxXTsKICAgICAgICAgICAgICAgICsrYjsKICAgICAgICAgICAgfQogICAgICAgICAgICArK2FuczsKICAgICAgICB9CiAgICB9CiAgICBjb3V0IDw8IGFuczsKICAgIHJldHVybiAwOwp9Cg==