#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int gcd(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int t;
  int a, b, g, n;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    if (n == 1) {
      scanf("%d", &a);
      if (a != 0)
        printf("NO\n");
      else
        printf("YES\n");
    } else {
      scanf("%d", &a);
      scanf("%d", &b);
      g = gcd(a, b);
      n = n - 2;
      while (n--) {
        scanf("%d", &a);
        if (g != 1) {
          g = gcd(g, a);
        }
      }
      if (g == 1)
        printf("YES\n");
      else
        printf("NO\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     1262 <main+0x132>
lea    0xe96(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x18(%rbp)
jne    11b9 <main+0x89>
lea    0xe7c(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
je     11a8 <main+0x78>
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
jmp    11b4 <main+0x84>
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
jmp    125d <main+0x12d>
lea    0xe40(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe30(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <gcd@plt>
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
cmp    $0x0,%eax
je     1231 <main+0x101>
lea    0xdf5(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x14(%rbp)
je     122c <main+0xfc>
mov    -0x14(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <gcd@plt>
mov    %eax,-0x14(%rbp)
jmp    11f0 <main+0xc0>
cmpl   $0x1,-0x14(%rbp)
jne    124c <main+0x11c>
lea    0xdc5(%rip),%rdi
call   1030 <printf@plt>
jmp    1258 <main+0x128>
lea    0xdb0(%rip),%rdi
call   1030 <printf@plt>
jmp    125d <main+0x12d>
jmp    114f <main+0x1f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <scanf@plt>
subl   $0x1,0x10(%rsp)
jae    1167 <main+0x37>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe92(%rip),%rbx
lea    0x8(%rsp),%r14
lea    0xc(%rsp),%r15
lea    0xe84(%rip),%r13
lea    0xe81(%rip),%r12
jmp    11a8 <main+0x78>
nopl   0x0(%rax,%rax,1)
cmpl   $0x0,0xc(%rsp)
mov    %r12,%rdi
cmove  %r13,%rdi
call   1030 <puts@plt>
subl   $0x1,0x10(%rsp)
jb     1156 <main+0x26>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%ebp
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
cmp    $0x1,%ebp
je     1190 <main+0x60>
mov    %rbx,%rdi
lea    0x14(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%edi
mov    0x14(%rsp),%esi
call   1050 <gcd@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%eax
lea    -0x3(%rax),%ecx
mov    %ecx,0x8(%rsp)
cmp    $0x2,%eax
jne    1209 <main+0xd9>
mov    %ebp,%eax
cmp    $0x1,%eax
jmp    1195 <main+0x65>
nopw   0x0(%rax,%rax,1)
subl   $0x1,0x8(%rsp)
mov    %eax,%ebp
jb     11f5 <main+0xc5>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    $0x1,%eax
cmp    $0x1,%ebp
je     1200 <main+0xd0>
mov    0xc(%rsp),%esi
mov    %ebp,%edi
call   1050 <gcd@plt>
jmp    1200 <main+0xd0>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"NO\0A\00"
@.str.2 = [5 x i8] c"YES\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %8
8: ; preds = %54, %0
%9 = load i32, i32* %2
%10 = add nsw i32 %9, -1
store i32 %10, i32* %2
%11 = icmp ne i32 %9, 0
br i1 %11, label %12, label %55
12: ; preds = %8
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%14 = load i32, i32* %6
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%18 = load i32, i32* %3
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %24
22: ; preds = %16
%23 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
br label %54
25: ; preds = %12
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = call i32 @gcd(i32 %28, i32 %29)
store i32 %30, i32* %5
%31 = load i32, i32* %6
%32 = sub nsw i32 %31, 2
store i32 %32, i32* %6
br label %33
33: ; preds = %45, %25
%34 = load i32, i32* %6
%35 = add nsw i32 %34, -1
store i32 %35, i32* %6
%36 = icmp ne i32 %34, 0
br i1 %36, label %37, label %46
37: ; preds = %33
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%39 = load i32, i32* %5
%40 = icmp ne i32 %39, 1
br i1 %40, label %41, label %45
41: ; preds = %37
%42 = load i32, i32* %5
%43 = load i32, i32* %3
%44 = call i32 @gcd(i32 %42, i32 %43)
store i32 %44, i32* %5
br label %45
45: ; preds = %41, %37
br label %33
46: ; preds = %33
%47 = load i32, i32* %5
%48 = icmp eq i32 %47, 1
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %53
51: ; preds = %46
%52 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %53
53: ; preds = %51, %49
br label %54
54: ; preds = %53, %24
br label %8
55: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@str.4 = [4 x i8] c"YES\00"
@str.5 = [3 x i8] c"NO\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = add nsw i32 %10, -1
store i32 %11, i32* %1
%12 = icmp eq i32 %10, 0
br i1 %12, label %52, label %13
13: ; preds = %0, %46
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 1
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br i1 %16, label %18, label %22
18: ; preds = %13
%19 = load i32, i32* %2
%20 = icmp eq i32 %19, 0
%21 = select i1 %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str.5, i64 0, i64 0)
br label %46
22: ; preds = %13
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call i32 @gcd(i32 %24, i32 %25)
%27 = load i32, i32* %4
%28 = add nsw i32 %27, -3
store i32 %28, i32* %4
%29 = icmp eq i32 %27, 2
br i1 %29, label %42, label %30
30: ; preds = %22, %37
%31 = phi i32 [ %38, %37 ], [ %26, %22 ]
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%33 = icmp eq i32 %31, 1
br i1 %33, label %37, label %34
34: ; preds = %30
%35 = load i32, i32* %2
%36 = call i32 @gcd(i32 %31, i32 %35)
br label %37
37: ; preds = %34, %30
%38 = phi i32 [ %36, %34 ], [ 1, %30 ]
%39 = load i32, i32* %4
%40 = add nsw i32 %39, -1
store i32 %40, i32* %4
%41 = icmp eq i32 %39, 0
br i1 %41, label %42, label %30
42: ; preds = %37, %22
%43 = phi i32 [ %26, %22 ], [ %38, %37 ]
%44 = icmp eq i32 %43, 1
%45 = select i1 %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str.5, i64 0, i64 0)
br label %46
46: ; preds = %42, %18
%47 = phi i8* [ %21, %18 ], [ %45, %42 ]
%48 = call i32 @puts(i8* dereferenceable(1) %47)
%49 = load i32, i32* %1
%50 = add nsw i32 %49, -1
store i32 %50, i32* %1
%51 = icmp eq i32 %49, 0
br i1 %51, label %52, label %13
52: ; preds = %46, %0
ret i32 0
}