#include <bits/stdc++.h>
using namespace std;
int main(void) {
  unordered_map<int, int> groups;
  int n;
  scanf("%d", &n);
  vector<int> v(n);
  for (int &i : v) {
    scanf("%d", &i);
  }
  for (int num : v) {
    groups[num]++;
  }
  int count = 0;
  count += groups[4];
  while (groups[3] > 0) {
    if (groups[1] >= 1) {
      groups[3] -= 1;
      groups[1] -= 1;
    } else {
      groups[3] -= 1;
    }
    count++;
  }
  while (groups[2] > 0) {
    if (groups[2] >= 2) {
      groups[2] -= 2;
    } else if (groups[1] >= 2) {
      groups[2] -= 1;
      groups[1] -= 2;
    } else if (groups[1] == 1) {
      groups[2] -= 1;
      groups[1] -= 1;
    } else {
      groups[2] -= 1;
    }
    count++;
  }
  while (groups[1] > 0) {
    if (groups[1] >= 4) {
      groups[1] -= 4;
    } else if (groups[1] < 4) {
      groups[1] = 0;
    } else {
      groups[1] -= 1;
    }
    count++;
  }
  cout << count;
}
