#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int erti = 0, ori = 0, sami = 0, otxi = 0;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == 1) erti++;
    if (x == 2) ori++;
    if (x == 3) sami++;
    if (x == 4) otxi++;
  }
  int ans = otxi;
  ans += ori / 2;
  ori %= 2;
  if (ori == 1) {
    ans++;
    if (erti > 2) {
      erti -= 2;
    } else {
      erti = 0;
    }
  }
  int d = min(erti, sami);
  erti -= d;
  sami -= d;
  ans += d;
  ans += sami;
  ans += (erti + 3) / 4;
  cout << ans << endl;
}
