#include <bits/stdc++.h>
using namespace std;
int n, a0, a1, a2, a3, a4, m;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < (n); i++) {
    int a;
    cin >> a;
    m += a;
    if (a == 0) a0++;
    if (a == 1) a1++;
    if (a == 2) a2++;
    if (a == 3) a3++;
    if (a == 4) a4++;
  }
  if (m == 1 || m == 2 || m == 5) return cout << -1 << endl, 0;
  int ans = 1070000000LL;
  stack<pair<long long, long long> > A_, A, B;
  A_.push(make_pair(a0, 0));
  A_.push(make_pair(a1, 1));
  A_.push(make_pair(a2, 2));
  A_.push(make_pair(a3, 3));
  A_.push(make_pair(a4, 4));
  for (int i = 0; i < (1070000000LL); i++) {
    if (i * 4 > m) break;
    if ((m - i * 4) % 3) continue;
    A = A_;
    int n4 = i;
    int n3 = (m - i * 4) / 3;
    int n0 = n - n4 - n3;
    if (n0 < 0) continue;
    B.push(make_pair(n0, 0));
    B.push(make_pair(n3, 3));
    B.push(make_pair(n4, 4));
    int res = 0;
    while (((int)(A).size()) && ((int)(B).size())) {
      pair<long long, long long> p = A.top();
      A.pop();
      pair<long long, long long> q = B.top();
      B.pop();
      int mi = min(p.first, q.first);
      res += mi * abs(p.second - q.second);
      if (p.first > mi) {
        A.push(make_pair(p.first - mi, p.second));
      }
      if (q.first > mi) {
        B.push(make_pair(q.first - mi, q.second));
      }
    }
    ans = min(ans, res / 2);
  }
  cout << (ans == 1070000000LL ? -1 : ans) << endl;
}
