1 #include<iostream> 2 using namespace std; 3 int main() 4 { 5 int n;cin>>n; 6 int one=0,two=0,three=0,four=0; 7 for(int i=0;i<n;i++) { 8 int x;cin>>x; 9 if(x==1) 10 one++; 11 else if(x==2) 12 two++; 13 else if(x==3) 14 three++; 15 else 16 four++; 17 } 18 int ans=0; 19 ans+=four; 20 ans+=three; 21 one-=three; 22 if(two%2==0) { 23 //even 24 ans+=two/2; 25 } 26 else { 27 //odd 28 ans+=two/2 +1; 29 one-=2; 30 } 31 //1 2 3 32 if(one>0) 33 ans+=(one+3)/4; 34 cout<<ans<<'\n'; 35 }