#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[100005];
  int n;
  while (cin >> n) {
    int b[5] = {0};
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      b[a[i]]++;
    }
    int temp = min(b[1], b[3]);
    int ans = b[4] + temp + b[2] / 2;
    b[1] -= temp;
    b[3] -= temp;
    int R2 = b[2] % 2;
    if (b[1] > b[3]) {
      if (R2 == 0) {
        ans += (b[1] + 3) / 4;
      } else {
        ans += (b[1] + 5) / 4;
      }
    } else if (b[1] < b[3]) {
      if (R2 == 0) {
        ans += b[3];
      } else {
        ans += b[3] + 1;
      }
    } else {
      if (R2 == 1) {
        ans += 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
