#include <bits/stdc++.h>
using namespace std;
int a[1000006], pre[1000006], c[5], tc[5], prec[1000006][5];
int main() {
  for (int N; scanf(" %d", &N) == 1;) {
    memset(c, 0, sizeof(c));
    for (int i = 1; i <= N; i++) {
      scanf(" %d", &a[i]);
      c[a[i]]++;
    }
    for (int i = 0; i < 5; i++) prec[0][i] = 0;
    sort(a + 1, a + N + 1);
    pre[0] = 0;
    for (int i = 1; i <= N; i++) {
      pre[i] = pre[i - 1] + a[i];
      for (int j = 0; j < 5; j++) prec[i][j] = prec[i - 1][j];
      prec[i][a[i]]++;
    }
    if (pre[N] == 0) {
      printf("0\n");
      continue;
    }
    if (pre[N] <= 2) {
      printf("-1\n");
      continue;
    }
    if (c[1] == 0 && c[2] == 0) {
      printf("0\n");
      continue;
    }
    int ans = pre[N];
    for (int i = 0; i <= N; i++) {
      for (int j = 0; j < 5; j++) tc[j] = c[j] - prec[i][j];
      int now = pre[i];
      int need = tc[1] * 2 + tc[2];
      int left = now - need;
      if (left == 0) {
        ans = min(ans, now);
      } else if (left < 0) {
        int still = -left;
        if (tc[4] >= still) ans = min(ans, now + still);
      } else {
        need = tc[1] + tc[2] + tc[3];
        if (left <= need) {
          ans = min(ans, now);
        }
      }
    }
    if (ans == pre[N]) ans = -1;
    printf("%d\n", ans);
  }
  return 0;
}
