#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  int one = 0, two = 0, three = 0, four = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 1)
      one++;
    else if (a[i] == 2)
      two++;
    else if (a[i] == 3)
      three++;
    else if (a[i] == 4)
      four++;
  }
  int ans = four + three;
  if (three >= one)
    one = 0;
  else
    one -= three;
  if (two % 2 == 0)
    ans += (two / 2);
  else {
    ans += two / 2 + 1;
    if (one < 2)
      one = 0;
    else
      one -= 2;
  }
  if (one % 4 == 0)
    ans += one / 4;
  else
    ans += one / 4 + 1;
  cout << ans;
}
