#include <bits/stdc++.h>
int main() {
  int n, i, j;
  scanf("%d", &n);
  int q[n], p[4];
  for (i = 0; i < n; i++) {
    scanf("%d", &q[i]);
  }
  for (i = 1; i <= 4; i++) {
    int a = 0;
    for (j = 0; j < n; j++) {
      if (q[j] == i) a += 1;
    }
    p[i - 1] = a;
  }
  int res = p[3], tem;
  res = res + p[2];
  p[0] = (p[0] - p[2] >= 0) ? (p[0] - p[2]) : 0;
  res = res + p[1] / 2;
  res = (p[1] % 2 != 0) ? res += 1 : res;
  p[0] = (p[1] % 2 == 0) ? p[0] : p[0] - 2;
  p[0] = (p[0] > 0) ? p[0] : 0;
  res = res + p[0] / 4;
  res = (p[0] % 4 == 0) ? res : res + 1;
  printf("%d", res);
  return 0;
}
