#include <bits/stdc++.h>
int main() {
  long int n, s, cnt, result = 0, one = 0, two = 0, three = 0;
  scanf("%li", &n);
  for (cnt = 1; cnt <= n; cnt++) {
    scanf("%li", &s);
    switch (s) {
      case 4:
        result++;
        break;
      case 3:
        three++;
        break;
      case 2:
        two++;
        break;
      case 1:
        one++;
    }
  }
  if (two % 2 == 0)
    result += two / 2;
  else if (one >= 2) {
    one -= 2;
    result += two / 2 + 1;
  } else if (one = 1) {
    one--;
    result += two / 2 + 1;
  } else
    result += two / 2 + 1;
  if (three <= one) {
    result += three;
    one -= three;
    three = 0;
  } else {
    result += one;
    three -= one;
    one = 0;
  }
  result += three;
  if (one % 4 == 0)
    result += one / 4;
  else
    result += one / 4 + 1;
  printf("%li", result);
}
