#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, n1 = 0, n2 = 0, n3 = 0, n4 = 0, tmp;
  cin >> n;
  while (n--) {
    cin >> tmp;
    if (tmp == 1)
      n1++;
    else if (tmp == 2)
      n2++;
    else if (tmp == 3)
      n3++;
    else
      n4++;
  }
  int ans = n4;
  if (n3 > n1) {
    n1 = 0;
    ans += n3;
    ans += (n2 + 1) / 2;
  } else {
    ans += n3;
    n1 -= n3;
    ans += n2 / 2;
    if (n2 % 2) {
      ans += (n1 + 2 + 3) / 4;
    } else
      ans += (n1 + 3) / 4;
  }
  cout << ans << endl;
  return 0;
}
