#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  map<long long, long long> mp;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    mp[v[i]]++;
  }
  ans += min(mp[1], mp[3]);
  mp[1] -= ans;
  mp[3] -= ans;
  ans += mp[2] / 2;
  mp[2] %= 2;
  if (mp[2] != 0) {
    ans++;
    mp[1] = max(0ll, mp[1] - 2);
  }
  ans += mp[3];
  ans += mp[4];
  ans += (mp[1] + 3) / 4;
  cout << ans << "\n";
  return 0;
}
