#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    if (a == 1) cnt1++;
    if (a == 2) cnt2++;
    if (a == 3) cnt3++;
    if (a == 4) cnt4++;
  }
  cnt += cnt4 + cnt2 / 2;
  cnt2 %= 2;
  if (cnt3 <= cnt1) {
    cnt += cnt3;
    cnt1 -= cnt3;
  } else {
    cnt += cnt3;
    cnt1 = cnt3 = 0;
  }
  if (cnt2 == 0) {
    cnt += (cnt1 % 4 == 0) ? cnt1 / 4 : cnt1 / 4 + 1;
  } else {
    if (cnt1 <= 2)
      cnt++;
    else {
      cnt++;
      cnt1 -= 2;
      cnt += (cnt1 % 4 == 0) ? cnt1 / 4 : cnt1 / 4 + 1;
    }
  }
  cout << cnt;
  return 0;
}
