#{{{ header import algorithm, sequtils, tables, macros, math, sets, strutils when defined(MYDEBUG): import header proc scanf(formatstr: cstring){.header: "", varargs.} proc getchar(): char {.header: "", varargs.} proc nextInt(): int = scanf("%lld",addr result) proc nextFloat(): float = scanf("%lf",addr result) proc nextString(): string = var get = false result = "" while true: var c = getchar() if int(c) > int(' '): get = true result.add(c) else: if get: break get = false template `max=`*(x,y:typed):void = x = max(x,y) template `min=`*(x,y:typed):void = x = min(x,y) template infty(T): untyped = ((T(1) shl T(sizeof(T)*8-2)) - 1) #}}} var pdiv: seq[int] proc sieve_of_eratosthenes(n:int):void = pdiv = newSeq[int](n) for i in 2..= n: break if pdiv[i] == i: for j in countup(i*i,n-1,i): pdiv[j] = i proc is_prime(n:int):bool = return n!=1 and pdiv[n]==n proc main():void = sieve_of_eratosthenes(2000) var N = nextInt() A = newSeqWith(N,nextInt()) pid = newSeq[int](2000) zero_ct = newSeqWith(N+1,0) ct = 0 for p in 2..<2000: if pdiv[p]==p: pid[p] = ct ct += 1 var t = newSeqWith(N+1,newSeq[int32](ct)) zero_ct[0] = 0 for i in 0.. a: break while a mod p==0: a = a div p t[i+1][pid[p]] += 1 if a > 1: t[i+1][pid[a]] += 1 var Q = nextInt() for _ in 0.. 0: echo "Yes" else: var valid = true for j in 0.. a: break if a mod p == 0: if p >= 2000: valid = false break while a mod p == 0: a = a div p u[pid[p]] += 1 if not valid: break if not valid: echo "NO" continue if a > 1: if a >= 2000: valid = false echo "NO" continue else: u[pid[a]] += 1 for i in 0..