import std.stdio, std.conv, std.math, std.string, std.range, std.array, std.algorithm; void main(){ auto T = readln().strip().to!int(); foreach(immutable i; 0 .. T) { auto N = readln().strip().to!int(); auto L = readln().strip().split().map!(to!int)().array; int bef = -1; int t = 1; L.sort(); auto tps = L.group().array(); tps.sort!"a[1] > b[1]"; int[] kadomatsu; kadomatsu.length = 3; foreach(tp; tps) { kadomatsu.minPos[0] += tp[1]; } writeln(kadomatsu.reduce!min()); } }