import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st;
static int zerocnt=0,onecnt=0,twocnt=0,threecnt=0,result=0,N;
public static void main(String args[])throws IOException{
N = Integer.parseInt(br.readLine());
st = new StringTokenizer(br.readLine()," ");
for(int i=0;i<N;i++){
int temp = Integer.parseInt(st.nextToken());
switch (temp) {
case 0:
zerocnt++;
break;
case 1:
onecnt++;
break;
case 2:
twocnt++;
break;
case 3:
threecnt++;
break;
default:
break;
}
}
//3
if(threecnt<=zerocnt){
zerocnt-=threecnt;
result+=3*threecnt;
threecnt=0;
}else{
threecnt-=zerocnt;
result+=3*zerocnt;
zerocnt=0;
}
if(onecnt<=twocnt){
twocnt-=onecnt;
result+=3*onecnt;
onecnt=0;
}else{
onecnt-=twocnt;
result+=3*twocnt;
twocnt=0;
}
//2
if(twocnt<=zerocnt){
zerocnt-=twocnt;
result+=2*twocnt;
twocnt=0;
}else{
twocnt-=zerocnt;
result+=2*zerocnt;
zerocnt=0;
}
if(onecnt<=threecnt){
threecnt-=onecnt;
result+=2*onecnt;
onecnt=0;
}else{
onecnt-=threecnt;
result+=2*threecnt;
threecnt=0;
}
//1
if(onecnt<=zerocnt){
zerocnt-=onecnt;
result+=1*onecnt;
onecnt=0;
}else{
onecnt-=zerocnt;
result+=1*zerocnt;
zerocnt=0;
}
if(twocnt<=threecnt){
threecnt-=twocnt;
result+=1*twocnt;
twocnt=0;
}else{
twocnt-=threecnt;
result+=1*threecnt;
threecnt=0;
}
System.out.println(result);
}
}
어느순간부터 백준 티어가 잘안올라가는거같다.
더 높은곳, 더 어려운문제에 도전을 할 생각을해야하는데 현생에 치여살다보니 그럴 여유가 없기도 하고, 좀 나태해진것같기도하다...... 이래살면안되는데 ㅠ