#include <bits/stdc++.h>
using namespace std;
int n, b[5];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    ++b[x];
  }
  int t = 0, c;
  c = min(b[1], b[2]);
  t += c;
  b[1] -= c;
  b[2] -= c;
  b[3] += c;
  c = b[1] / 3;
  t += 2 * c;
  b[1] -= 3 * c;
  b[3] += c;
  c = min(b[1] / 2, b[4]);
  t += 2 * c;
  b[1] -= 2 * c;
  b[4] -= c;
  b[3] += 2 * c;
  c = min(b[1], b[3]);
  t += c;
  b[1] -= c;
  b[3] -= c;
  b[4] += c;
  c = min(b[1], b[4] / 2);
  t += 2 * c;
  b[1] -= c;
  b[4] -= 2 * c;
  b[3] += 3 * c;
  c = b[2] / 3;
  t += 2 * c;
  b[2] -= 3 * c;
  b[3] += 2 * c;
  c = b[2] / 2;
  t += 2 * c;
  b[2] -= 2 * c;
  b[4] += c;
  c = min(b[2], b[4]);
  t += c;
  b[2] -= c;
  b[4] -= c;
  b[3] += 2 * c;
  c = min(b[2], b[3] / 2);
  t += 2 * c;
  b[2] -= c;
  b[3] -= 2 * c;
  b[4] += 2 * c;
  if (b[1] || b[2]) t = -1;
  printf("%d\n", t);
  return 0;
}
