#include <bits/stdc++.h>
using namespace std;
int n, x1, x2, x3, x4;
int x, a[1000005], m[5];
int tot = 0;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    m[a[i]]++;
  }
  int ans = 0;
  while (m[1] > 0 || m[2] > 0) {
    if (m[1] > 0 && m[2] > 0) {
      m[1]--;
      m[2]--;
      m[3]++;
      ans++;
    } else if (m[1] > 0) {
      if (m[1] >= 3) {
        m[1] -= 3;
        m[3]++;
        ans += 2;
      } else {
        if (m[4] > 0 && m[1] == 2) {
          m[4]--;
          m[1] = 0;
          m[3] += 2;
          ans += 2;
        } else if (m[3] > 0) {
          m[3]--;
          m[1]--;
          m[4]++;
          ans++;
        } else if (m[4] >= 2 && m[1] == 1) {
          m[1] = 0;
          ans += 2;
        } else {
          printf("-1\n");
          return 0;
        }
      }
    } else if (m[2] > 0) {
      if (m[2] >= 3) {
        ans += 2;
        m[2] -= 3;
        m[3] += 2;
      } else {
        if (m[2] == 1) {
          if (m[4]) {
            m[4]--;
            m[2] = 0;
            m[3] += 2;
            ans++;
          } else if (m[3] >= 2) {
            m[3] -= 2;
            m[2] = 0;
            ans += 2;
          } else {
            printf("-1\n");
            return 0;
          }
        } else if (m[2] == 2) {
          ans += 2;
          m[2] = 0;
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
