import sequtils,algorithm,math,tables import sets,intsets,queues,heapqueue,bitops,strutils template times*(n:int,body) = (for _ in 0.." .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': break result = 10 * result + k.ord - '0'.ord proc solve() : int = let n = scan() let L = newSeqWith(n,scan()).sorted(cmp) var R = @[1] for i in 1.. 0: result += 1 R[0] -= 1 R[1] -= 1 R[2] -= 1 R.sort(cmp,Descending) scan().times:echo solve()