#include <bits/stdc++.h>
int get();
int main() {
  int x[4] = {0, 0, 0, 0};
  for (int i(get()); 0 < i--; ++x[get() - 1])
    ;
  *x -= std::min(*x, x[2]);
  x[3] += x[2] + x[1] / 2;
  if (x[1] & 1) ++x[3], *x = std::max(0, *x - 2);
  std::printf("%d\n", x[3] + (*x + 3) / 4);
  return (0);
}
int get() {
  int var;
  std::scanf("%d\n", &var);
  return (var);
}
