#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; static const double EPS = 1e-8; static const double PI = 4.0 * atan(1.0); static const double PI2 = 8.0 * atan(1.0); #define REP(i,n) for(int i=0;i<(int)n;++i) #define ALL(c) (c).begin(),(c).end() #define CLEAR(v) memset(v,0,sizeof(v)) #define MP(a,b) make_pair((a),(b)) #define ABS(a) ((a)>0?(a):-(a)) #define FOR(i,s,n) for(int i=s;i<(int)n;++i) int N; int L[100]; vector cnt; void solve() { cin >> N; REP(i, N) cin >> L[i]; sort(L, L + N); cnt.clear(); int c = 0; FOR(i, 1, N) { ++c; if (L[i] == L[i - 1]) continue; cnt.push_back(c); c = 0; } cnt.push_back(++c); sort(ALL(cnt)); reverse(ALL(cnt)); int res = 0; bool f, g; REP(i, cnt.size()) { while (cnt[i] > 0) { f = false; FOR(j, i + 1, cnt.size()) if (cnt[j] > 0) { FOR(k, j + 1, cnt.size()) if (cnt[k] > 0) { --cnt[i]; --cnt[j]; --cnt[k]; ++res; f = true; break; } if (f) break; } if (!f) break; } } cout << res << endl; } int main(int argc, char **argv) { int T; cin >> T; REP(i, T) solve(); return 0; }