@@ -0,0 +1,707 @@
+import collections, sys%0A%0Aif __name__ == '__main__':%0A    T = int(sys.stdin.readline())%0A    %0A    for _ in range(T):%0A        N = int(sys.stdin.readline())%0A        c = list(map(int, sys.stdin.readline().split()))%0A        count = collections.Counter(c)%0A        n = 0%0A        combinations = 1%0A        possible_terms = 0%0A        %0A        while True:%0A            if n in count:%0A                possible_terms += count%5Bn%5D%0A            %0A            if possible_terms %3E 0:%0A                combinations *= possible_terms%0A                combinations %25= 1000000007%0A                possible_terms -= 1%0A                n += 1%0A            else:%0A                break%0A        %0A        print(0 if n %3C max(c) else combinations)

add picking-cards