#include <bits/stdc++.h>
int a[100010];
int main() {
  int n;
  int b = 0, c = 0, d = 0, td = 0, ex1 = 0, ex2 = 0, ex;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 1)
      b++;
    else if (a[i] == 2)
      c++;
    else if (a[i] == 3)
      d++;
    else if (a[i] == 4)
      td++;
  }
  td += d;
  if (c % 2 == 0) {
    td += (c / 2);
  } else {
    ex2 = (c % 2);
    td += (c / 2);
  }
  if (b > d) {
    ex1 = b - d;
  }
  ex = (2 * ex2) + ex1;
  if (ex % 4 == 0)
    td += (ex / 4);
  else
    td += (ex / 4) + 1;
  printf("%d", td);
  return 0;
}
