#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
#define endl "\n"
void solve()
{
    ll n, ans = 0;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    ll sum = a[0];
    for (auto i : a)
    {
        sum += i;
        ll avg = sum / 2;
        if (i > avg)
            ans++;
        sum -= i;
    }
    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}