#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
 
#define MOD 1000000009

int main(){
  int t;
  cin>>t;
  rep(a,0,t){
    int n;
    cin>>n;
    map<int,int> ma;
    rep(i,0,n){
      int b;
      cin>>b;
      ma[b]++;
    }
    map<int,int>::iterator itr = ma.begin();
    vector<int> v;
    while(itr!=ma.end()){
      v.pb((*itr).se);
      itr++;
    }
    v.pb(0);
    v.pb(0);
    v.pb(0);
    int ans = 0;
    for(;;){
      sort(all(v),greater<int>());
      if(v[2]==0)break;
      ans++;
      v[0]--;
      v[1]--;
      v[2]--;
    }
    cout << ans <<endl;
  }  
  return 0;
}