import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int j = 0; j < t; j++) { int n = sc.nextInt(); HashMap map = new HashMap<>(); int max = 1; for (int i= 0; i < n; i++) { int x = sc.nextInt(); if (map.containsKey(x)) { map.put(x, map.get(x) + 1); max = Math.max(max, map.get(x)); } else { map.put(x, 1); } } sb.append(Math.min(n / 3, (n - max) / 2)).append("\n"); } System.out.print(sb); } }