import std.algorithm, std.array, std.container, std.range; import std.string, std.conv; import std.math, std.bigint, std.bitmanip, std.random; import std.stdio, std.typecons; const auto mod = 10 ^^ 9 + 7; void main() { auto t = readln.chomp.to!int; foreach (_; 0..t) { auto n = readln.chomp.to!int; auto ai = readln.split.map!(to!int).array; ai.sort(); auto hi = heapify(ai.group.map!("a[1].to!int").array); writeln(calc(hi, 0)); } } int calc(BinaryHeap!(int[]) hi, int acc) { auto r = 0; while (hi.length >= 3) { auto ai = hi.take(3).array; ai[] -= 1; foreach (a; ai) { if (a > 0) hi.insert(a); } r += 1; } return r; }