import java.util.Scanner;

public class Test {
public static void main (String[] args ){
Scanner s=new Scanner(System.in);
int n=s.nextInt();
int count=0,count1=0,count2=0,count3=0,countz=0;
int[] f=new int[n];
for(int i=0;i<n;i++){
f[i]=s.nextInt();
if(f[i]==4)
count++;
else if(f[i]==3)
count3++;
else if(f[i]==2)
count2++;
else 
count1++;}
if(count3>=count1)
  {count=count+count3;
  count1=0;}
else
{count=count+count3;
count1=count1-count3;}
if(count2%2==0)
count=count+(int)(count2/2);
else 
{count=count+(int)(count2/2)+1;
count1=count1-2;}
if(count1%4==0&&count1>0)
count=count+count1/4;
else if(count1>0)
count=count+count1/4+1;
else
countz++;
System.out.println(count);
  }}