#include <bits/stdc++.h>
using namespace std;
int k, r[1000005], w1, w2, w3, w4, y, i, n;
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> r[i];
  for (i = 1; i <= n; i++) {
    if (r[i] == 1) w1++;
    if (r[i] == 2) w2++;
    if (r[i] == 3) w3++;
    if (r[i] == 4) w4++;
  }
  w1 = max(w1 - w3, 0);
  cout << w3 + w4 + (w1 + 2 * w2 + 3) / 4;
}
