#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a = 0, b = 0, c = 0, d = 0, e, f, g, z;
  cin >> n;
  int x[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    if (x[i] == 1)
      a++;
    else if (x[i] == 2)
      b++;
    else if (x[i] == 3)
      c++;
    else if (x[i] == 4)
      d++;
  }
  e = c - a;
  if (e == 0) {
    if (b > 0)
      z = d + c + ((b - 1) / 2) + 1;
    else
      z = d + c;
    cout << z << endl;
  } else if (e < 0) {
    e *= -1;
    if (b % 2 == 0) {
      z = d + c + b / 2 + ((e - 1) / 4) + 1;
      cout << z << endl;
    } else {
      e -= 2;
      if (e <= 0) {
        z = d + c + b / 2 + 1;
        cout << z << endl;
      } else {
        if (b > 0)
          z = d + c + (b - 1) / 2 + 1 + ((e - 1) / 4) + 1;
        else
          z = d + c + ((e - 1) / 4) + 1;
        cout << z << endl;
      }
    }
  } else {
    if (b > 0)
      z = d + c + (b - 1) / 2 + 1;
    else
      z = d + c;
    cout << z << endl;
  }
  return 0;
}
