/*

                                  In the name of Allah, Most Gracious, Most Merciful


*/
#include <bits/stdc++.h>
#include<numeric>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define fr(i, a, b) for (ll i=a; i<(b); i++)
#define fn(i, a) for (ll i=0; i<(a); i++)
#define frd(i,a,b) for (ll i = (b)-1; i >= a; i--)
#define fnd(i,a) for (ll i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define tt cout<<"\nCame here"<<endl;

const double EPS = 1e-6 ;
const long double PI = 3.141592653589793238;

void solve()
{
    ll n;
    cin >> n;
    vl v(n);
    ll sum = 0;
    fn(i,n)
    {
        cin >> v[i];
        sum += v[i];
    }

    if(n == 1)
    {
        cout << 0 << endl;
        return;
    }
    else if(sum%n)
    {
        cout << -1 << endl;
        return;
    }

    ll per = sum / n;
    sort(v.rbegin(), v.rend());

    ll pre;

    fn(i,n)
    {
        if(per >= v[i])
        {
            cout << i << endl;
            return;
        }
    }
}

int main()
{
    IOS;
    ll tc = 1;
    cin>>tc;
    fn(i,tc)
    solve();


    return 0;
}

