import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Map; import java.util.PriorityQueue; import java.util.Scanner; import java.util.Set; import java.util.Map.Entry; public class Main { public static class Bamboo implements Comparable { int len, count; public Bamboo(int len, int count) { super(); this.len = len; this.count = count; } @Override public int compareTo(Bamboo o) { if(Integer.compare(o.count, this.count) != 0){ return Integer.compare(o.count, this.count); }else{ return Integer.compare(this.len, o.len); } } } public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int T = sc.nextInt(); for(int tt = 0; tt < T; tt++){ final int N = sc.nextInt(); Map map = new HashMap(); for(int i = 0; i < N; i++){ final int l = sc.nextInt(); if(!map.containsKey(l)){ map.put(l, 0); } map.put(l, map.get(l) + 1); } PriorityQueue queue = new PriorityQueue(); for(Entry entry : map.entrySet()){ queue.add(new Bamboo(entry.getKey(), entry.getValue())); } int count = 0; while(queue.size() >= 3){ final Bamboo fst = queue.poll(); final Bamboo snd = queue.poll(); final Bamboo thd = queue.poll(); count++; if(fst.count > 1){ fst.count--; queue.add(fst); } if(snd.count > 1){ snd.count--; queue.add(snd); } if(thd.count > 1){ thd.count--; queue.add(thd); } } System.out.println(count); } } }