#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
int a, b, c, d, n, m, k;
int beg[5], cur[5];
int solve(int f) {
  int t = (m - f * 4) / 3;
  memmove(cur, beg, sizeof(cur));
  int ans = 0;
  int d = min(f, cur[4]);
  f -= d;
  cur[4] -= d;
  d = min(f, min(cur[3], cur[1]));
  f -= d;
  cur[3] -= d;
  cur[1] -= d;
  ans += d;
  d = min(f, min(cur[2] * 2, cur[3]));
  if (d % 2) --d;
  f -= d;
  cur[2] -= d / 2;
  cur[3] -= d;
  ans += d;
  if (cur[2] && cur[3] && f) {
    --cur[2];
    ++cur[1];
    --cur[3];
    --f;
    ++ans;
  }
  d = min(cur[3] / 4, f / 3);
  f -= d * 3;
  ans += d * 3;
  cur[3] -= d * 4;
  while (f) {
    if (!cur[3]) break;
    if (cur[1]) {
      --f;
      --cur[3];
      --cur[1];
      ++ans;
      continue;
    }
    if (cur[2]) {
      --f;
      --cur[3];
      --cur[2];
      ++cur[1];
      ++ans;
      continue;
    }
    if (cur[3] > 1) {
      --f;
      --cur[3];
      --cur[3];
      ++cur[2];
      ++ans;
      continue;
    }
    break;
  }
  d = min(f, min(cur[1] / 2, cur[2]));
  f -= d;
  ans += d * 2;
  cur[1] -= d * 2;
  cur[2] -= d;
  d = min(f, cur[2] / 2);
  f -= d;
  ans += d * 2;
  cur[2] -= d * 2;
  if (f && cur[2]) {
    --cur[2];
    cur[1] -= 2;
    --f;
    ans += 2;
  }
  ans += f * 3;
  cur[1] -= f * 4;
  f = 0;
  ans += cur[4];
  if (cur[4]) {
    if (cur[2] >= cur[4]) {
      cur[3] += 2 * cur[4];
      cur[2] -= cur[4];
      cur[4] = 0;
    } else {
      cur[3] += 2 * cur[2];
      cur[4] -= cur[2];
      cur[2] = 0;
      int can = min(cur[1], cur[4] / 2);
      cur[3] += can * 3;
      cur[1] -= can;
      cur[4] -= can * 2;
      if (cur[1] >= cur[4]) {
        cur[2] += cur[4];
        cur[1] -= cur[4];
        cur[3] += cur[4];
        cur[4] = 0;
      } else {
        cur[4] -= cur[1];
        cur[2] += cur[1];
        cur[3] += cur[1];
        cur[1] = 0;
        cur[1] += cur[4];
        cur[3] += cur[4];
        cur[4] = 0;
      }
    }
  }
  t -= cur[3];
  cur[3] = 0;
  d = min(cur[2], cur[1]);
  ans += d;
  t -= d;
  cur[2] -= d;
  cur[1] -= d;
  d = min(t, cur[2] / 3);
  t -= d * 2;
  ans += d * 2;
  cur[2] -= d * 3;
  if (cur[2] == 2) {
    ++cur[1];
    --t;
    ++ans;
    cur[2] -= 2;
  }
  ans += t * 2;
  t = 0;
  return ans;
}
int main() {
  scanf("%d", &n);
  m = 0;
  for (int _n((n)-1), i(0); i <= _n; i++) {
    scanf("%d", &a);
    ++beg[a];
    m += a;
  }
  int ans = 1000000000;
  for (int _n((m + 1) - 1), four(0); four <= _n; four++) {
    if (four * 4 > m) break;
    int rem = m - four * 4;
    if (rem % 3) continue;
    int cur = solve(four);
    ans = min(ans, cur);
  }
  if (ans == 1000000000)
    printf("-1\n");
  else
    printf("%d\n", ans);
}
