#include <bits/stdc++.h>
using namespace std;
string stoc(char);
int main() {
  int n;
  cin >> n;
  int arr[] = {0, 0, 0, 0, 0};
  int t;
  for (int i = 0; i < n; i++) {
    cin >> t;
    arr[t]++;
  };
  arr[1] = max(arr[1] - arr[3], 0);
  cout << arr[4] + arr[3] + (arr[2] * 2 + arr[1] + 3) / 4;
}
string ctos(char c) {
  string a;
  a.append(1, c);
  return a;
}
