class Yukicoder def initialize t = gets.to_i t.times do n = gets.to_i l = gets.chomp.split.map(&:to_i) take = Array.new(101, 0) l.each do |i| take[i] += 1 end take = take.sort_by{|i| -i} answer = 0 while take[2] > 0 answer += take[2] take[0] -= take[2] take[1] -= take[2] take[2] -= take[2] take = take.sort_by{|i| -i} end puts answer end end end Yukicoder.new