#include <bits/stdc++.h>
using namespace std;
long int min(long int a, long int b) {
  if (a > b) return b;
  return a;
}
int main() {
  long int s[5] = {0};
  long int n;
  scanf("%li", &n);
  long int x, i;
  for (i = 0; i < n; i++) {
    scanf("%li", &x);
    s[x]++;
  }
  long long int ans = 0;
  ans = s[4] + s[2] / 2;
  s[2] = s[2] % 2;
  long int k = min(s[3], s[1]);
  ans += k;
  s[3] -= k;
  s[1] -= k;
  if (s[3] > 0) ans += s[3];
  if (s[1] >= 1 && s[2] == 1) {
    ans++;
    s[2] = 0;
    s[1]--;
    if (s[1] > 0) s[1]--;
  }
  if (s[2] == 1) ans++;
  ans += s[1] / 4;
  s[1] = s[1] % 4;
  if (s[1] > 0) ans++;
  printf("%lli\n", ans);
  return 0;
}
