#include<iostream>
using namespace std;
int main()
{
long long int n;
int x=0,count=0,c4=0,c3=0,c2=0,c1=0;
cin>>n;
while(n--)
{
cin>>x;
if(x==4)
c4++;
else if(x==3)
c3++;
else if(x==2)
c2++;
else if(x==1)
c1++;
}
// cout<<c4<<" "<<c3<<" "<<c2<<" "<<c1<<endl;
count+=c4;
c4=0;
if(c3>=c1)
{
count+=c3;
c3=c1=0;
}
else
{
count+=c3;
c1-=c3;
c3=0;
}
if(c2>=c1)
{
if(c1%2==0)
{
c1/=2;
count+=c1;
c2-=c1;
}
else
{
c1+=1;
c1/=2;
count+=c1;
c2-=c1;
}
if(c2>=2)c2/=2;
count+=c2;
}
else
{
if(c1%2==0)
{
c1/=2;
count+=c2;
c1-=c2;
}
else
{
c1+=1;
c1/=2;
count+=c2;
c1-=c2;
}
if(c1>=2)c1/=2;
count+=c1;
}
cout<<count<<endl;
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBtYWluKCkKewogICAgbG9uZyBsb25nIGludCBuOwogICAgaW50IHg9MCxjb3VudD0wLGM0PTAsYzM9MCxjMj0wLGMxPTA7CiAgICBjaW4+Pm47CiAgICB3aGlsZShuLS0pCiAgICB7CiAgICAgICAgY2luPj54OwogICAgICAgIGlmKHg9PTQpCiAgICAgICAgICAgIGM0Kys7CiAgICAgICAgZWxzZSBpZih4PT0zKQogICAgICAgICAgICBjMysrOwogICAgICAgIGVsc2UgaWYoeD09MikKICAgICAgICAgICAgYzIrKzsKICAgICAgICBlbHNlIGlmKHg9PTEpCiAgICAgICAgICAgIGMxKys7CiAgICB9CgovLyAgICBjb3V0PDxjNDw8IiAiPDxjMzw8IiAiPDxjMjw8IiAiPDxjMTw8ZW5kbDsKICAgIGNvdW50Kz1jNDsKICAgIGM0PTA7CiAgICBpZihjMz49YzEpCiAgICB7CiAgICAgICAgY291bnQrPWMzOwogICAgICAgIGMzPWMxPTA7CiAgICB9CiAgICBlbHNlCiAgICB7CiAgICAgICAgY291bnQrPWMzOwogICAgICAgIGMxLT1jMzsKICAgICAgICBjMz0wOwogICAgfQogICAgaWYoYzI+PWMxKQogICAgewogICAgICAgIGlmKGMxJTI9PTApCiAgICAgICAgewogICAgICAgICAgICBjMS89MjsKICAgICAgICAgICAgY291bnQrPWMxOwogICAgICAgICAgICBjMi09YzE7CiAgICAgICAgfQogICAgICAgIGVsc2UKICAgICAgICB7CiAgICAgICAgICAgIGMxKz0xOwogICAgICAgICAgICBjMS89MjsKICAgICAgICAgICAgY291bnQrPWMxOwogICAgICAgICAgICBjMi09YzE7CiAgICAgICAgfQogICAgICAgIGlmKGMyPj0yKWMyLz0yOwogICAgICAgIGNvdW50Kz1jMjsKICAgIH0KICAgIGVsc2UKICAgIHsKICAgICAgICBpZihjMSUyPT0wKQogICAgICAgIHsKICAgICAgICAgICAgYzEvPTI7CiAgICAgICAgICAgIGNvdW50Kz1jMjsKICAgICAgICAgICAgYzEtPWMyOwogICAgICAgIH0KICAgICAgICBlbHNlCiAgICAgICAgewogICAgICAgICAgICBjMSs9MTsKICAgICAgICAgICAgYzEvPTI7CiAgICAgICAgICAgIGNvdW50Kz1jMjsKICAgICAgICAgICAgYzEtPWMyOwogICAgICAgIH0KICAgICAgICBpZihjMT49MiljMS89MjsKICAgICAgICBjb3VudCs9YzE7CiAgICB9CiAgICBjb3V0PDxjb3VudDw8ZW5kbDsKICAgIHJldHVybiAwOwp9Cg==