/** これを翻訳している間、あなたはあなたの人生のいくつかの貴重な瞬間を無駄にしました **/
#include<bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define memo(x,y) memset((x),(y),sizeof((x)))
#define line cout<<"[At "<<__LINE__<<"]"<<endl;

using pii = pair<int,int>;
using vi = vector<int>;
using vii = vector<pair<int,int>>;

constexpr int mod = 1e9 + 7 , N = 2e5 + 5;
constexpr long long inf = 1e18;
constexpr long double eps = 1e-6; 


void Onigiri()
{
  int n;
  cin>>n;
  int a[n];
  map<int,int> mpp;
  rep(i,0,n){
    cin>>a[i];
    mpp[a[i]]++;
  }
  vi v;
  for(auto &x:mpp){
    v.pb(x.ss);
  }
  sort(all(v));
  
  if(v[0]==v.back()){cout<<0;return;}
  
  int prev=0,nxt=accumulate(all(v),0LL);
  int ans=n;
  n=sz(v);
  rep(i,0,n){
    int cnt=0,tempsum=0;
    while(i+1<n&&v[i]==v[i+1]){cnt++;tempsum+=v[i];nxt-=v[i];i++;}
    nxt-=v[i];
    //cout<<prev<<"+"<<nxt<<"-"<<v[i]<<"*("<<n-i<<")"<<endl;
    ans=min(ans,prev+nxt-v[i]*(n-i-1));
    prev+=tempsum+v[i];
  }
  cout<<ans;
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   //cout.precision(10);cout<<fixed;
   #ifdef Zoro
   freopen("/home/pritish/Competitive/in", "r", stdin);
   freopen("/home/pritish/Competitive/out", "w", stdout);
   #endif  
 
   int t=1; 
   cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}
### Prompt

Please create a solution in Cpp to the following problem:

Polycarp was gifted an array a of length n. Polycarp considers an array beautiful if there exists a number C, such that each number in the array occurs either zero or C times. Polycarp wants to remove some elements from the array a to make it beautiful.

For example, if n=6 and a = [1, 3, 2, 1, 4, 2], then the following options are possible to make the array a array beautiful: 

  * Polycarp removes elements at positions 2 and 5, array a becomes equal to [1, 2, 1, 2]; 
  * Polycarp removes elements at positions 1 and 6, array a becomes equal to [3, 2, 1, 4]; 
  * Polycarp removes elements at positions 1, 2 and 6, array a becomes equal to [2, 1, 4]; 



Help Polycarp determine the minimum number of elements to remove from the array a to make it beautiful.

Input

The first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.

The first line of each test case consists of one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the length of the array a.

The second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) — array a.

It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.

Output

For each test case, output one integer — the minimum number of elements that Polycarp has to remove from the array a to make it beautiful.

Example

Input


3
6
1 3 2 1 4 2
4
100 100 4 100
8
1 2 3 3 3 2 6 6


Output


2
1
2

### Response

```cpp
/** これを翻訳している間、あなたはあなたの人生のいくつかの貴重な瞬間を無駄にしました **/
#include<bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define memo(x,y) memset((x),(y),sizeof((x)))
#define line cout<<"[At "<<__LINE__<<"]"<<endl;

using pii = pair<int,int>;
using vi = vector<int>;
using vii = vector<pair<int,int>>;

constexpr int mod = 1e9 + 7 , N = 2e5 + 5;
constexpr long long inf = 1e18;
constexpr long double eps = 1e-6; 


void Onigiri()
{
  int n;
  cin>>n;
  int a[n];
  map<int,int> mpp;
  rep(i,0,n){
    cin>>a[i];
    mpp[a[i]]++;
  }
  vi v;
  for(auto &x:mpp){
    v.pb(x.ss);
  }
  sort(all(v));
  
  if(v[0]==v.back()){cout<<0;return;}
  
  int prev=0,nxt=accumulate(all(v),0LL);
  int ans=n;
  n=sz(v);
  rep(i,0,n){
    int cnt=0,tempsum=0;
    while(i+1<n&&v[i]==v[i+1]){cnt++;tempsum+=v[i];nxt-=v[i];i++;}
    nxt-=v[i];
    //cout<<prev<<"+"<<nxt<<"-"<<v[i]<<"*("<<n-i<<")"<<endl;
    ans=min(ans,prev+nxt-v[i]*(n-i-1));
    prev+=tempsum+v[i];
  }
  cout<<ans;
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   //cout.precision(10);cout<<fixed;
   #ifdef Zoro
   freopen("/home/pritish/Competitive/in", "r", stdin);
   freopen("/home/pritish/Competitive/out", "w", stdout);
   #endif  
 
   int t=1; 
   cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}
```