#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
template <class T>
typename T::value_type arr_sum(const T& v, int n) {
  typename T::value_type sum = 0;
  for (int i = (0); i < (n); ++i) sum += v[i];
  return sum;
}
struct Sync_stdio {
  Sync_stdio() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
  }
} _sync_stdio;
int dist(vector<int> v, vector<int> v2) {
  int res = 0;
  while (v.size() && v2.size()) {
    res += abs(int(v.size()) - int(v2.size())) * (min(v2.back(), v.back()));
    if (v.back() < v2.back()) {
      v2[v2.size() - 1] -= v.back();
      v.pop_back();
    } else {
      v[v.size() - 1] -= v2.back();
      v2.pop_back();
    }
  }
  for (int i = (0); i < (int(v.size())); ++i) {
    res += v[i] * i;
  }
  for (int i = (0); i < (int(v2.size())); ++i) {
    res += v2[i] * i;
  }
  assert(res % 2 == 0);
  return res / 2;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> v(5);
  for (int i = (0); i < (n); ++i) {
    int x;
    scanf("%d", &x);
    ++v[x];
  }
  int s = 0;
  for (int i = (0); i < (5); ++i) {
    s += v[i] * i;
  }
  int ans = INT_MAX;
  for (int i = (0); i < (n + 1); ++i) {
    vector<int> v2(5);
    if (s - 4 * i < 0 || (s - 4 * i) % 3 != 0) {
      continue;
    }
    v2[4] = i;
    v2[3] = (s - 4 * i) / 3;
    v2[0] = n - v2[4] - v2[3];
    vector<int> v3 = v;
    if (v2[0] < 0) {
      v3[0] -= v2[0];
      v2[0] = 0;
    }
    ans = min(ans, dist(v2, v3));
  }
  cout << (ans == INT_MAX ? -1 : ans);
}
