#include <bits/stdc++.h>
int main() {
  int n, count[5], i, temp, counts = 0;
  for (i = 0; i < 5; i++) {
    count[i] = 0;
  }
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &temp);
    count[temp]++;
  }
  counts = counts + count[4];
  if (count[3] >= count[1]) {
    counts = counts + count[3] + (count[2] / 2) + (count[2] % 2);
  } else {
    counts = counts + count[3];
    count[1] = count[1] - count[3];
    if (count[2] % 2 == 0) {
      if (count[1] % 4 == 0) {
        counts = counts + (count[2] / 2) + (count[1] / 4);
      } else {
        counts = counts + (count[2] / 2) + (count[1] / 4) + 1;
      }
    } else {
      if (count[1] <= 2) {
        counts = counts + (count[2] / 2) + 1;
      } else {
        if ((count[1] - 2) % 4 != 0) {
          counts = counts + (count[2] / 2) + ((count[1] - 2) / 4) + 2;
        } else {
          counts = counts + (count[2] / 2) + ((count[1] - 2) / 4) + 1;
        }
      }
    }
  }
  printf("%d\n", counts);
  return 0;
}
