import math T = int(input()) for _ in range(T): N = int(input()) A = list(map(int, input().split())) v = 1 for a in A: g = math.gcd(v,a) a = a//g v = v//g v = v*a if v == math.isqrt(v)**2: print('Yes') else: print('No')