def solve() : N = int(input()) A = [int(x) for x in input().split()] print(min(A) * max(A)) T = int(input()) for _ in range(T) : solve()