#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 */
long gcd(long, long);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, long *);
int main() {
  long int t, i, j, k, n, count = 0, flag = 0, ss = 0;
  ;
  scanf("%ld", &t);
  for (i = 0; i < t; i++) {
    scanf("%ld", &n);
    long int a[n];
    for (j = 0; j < n; j++) {
      scanf("%ld", &a[j]);
    }
    ss = gcd(a[0], a[1]);
    for (j = 0; j < n - 1; j++) {
      if (ss == 1) {
        flag = 1;
        break;
      }
      ss = gcd(ss, a[j]);
    }
    if (flag == 1)
      printf("YES\n");
    else
      printf("NO\n");
    flag = 0;
    ss = 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
lea    0xea2(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    12ba <main+0x18a>
lea    0xe7c(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x30(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x50(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x30(%rbp),%rax
jge    11f7 <main+0xc7>
mov    -0x60(%rbp),%rsi
mov    -0x20(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe1f(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11bd <main+0x8d>
mov    -0x60(%rbp),%rax
mov    (%rax),%rdi
mov    0x8(%rax),%rsi
call   1050 <gcd@plt>
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jge    126a <main+0x13a>
cmpq   $0x1,-0x48(%rbp)
jne    1240 <main+0x110>
movq   $0x1,-0x40(%rbp)
jmp    126a <main+0x13a>
mov    -0x60(%rbp),%rax
mov    -0x48(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <gcd@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1213 <main+0xe3>
cmpq   $0x1,-0x40(%rbp)
jne    1286 <main+0x156>
lea    0xd88(%rip),%rdi
call   1030 <printf@plt>
jmp    1292 <main+0x162>
lea    0xd7c(%rip),%rdi
call   1030 <printf@plt>
movq   $0x0,-0x40(%rbp)
movq   $0x1,-0x48(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,%rsp
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    116f <main+0x3f>
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeb8(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1040 <scanf@plt>
cmpq   $0x0,-0x38(%rbp)
jle    1234 <main+0x104>
xor    %r12d,%r12d
lea    0xe9a(%rip),%r15
jmp    118e <main+0x5e>
nopl   0x0(%rax,%rax,1)
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
mov    -0x40(%rbp),%rsp
add    $0x1,%r12
cmp    -0x38(%rbp),%r12
jge    1234 <main+0x104>
mov    %r15,%rdi
lea    -0x30(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rsp,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    %rsp,%r13
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %r13,%rbx
xor    %r14d,%r14d
nopl   (%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    $0x1,%r14
add    $0x8,%rbx
cmp    -0x30(%rbp),%r14
jl     11c0 <main+0x90>
mov    0x0(%r13),%rdi
mov    0x8(%r13),%rsi
call   1050 <gcd@plt>
cmpq   $0x2,-0x30(%rbp)
lea    0xe12(%rip),%rdi
jl     1177 <main+0x47>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
cmp    $0x1,%rax
je     1170 <main+0x40>
mov    0x0(%r13,%rbx,8),%rsi
mov    %rax,%rdi
call   1050 <gcd@plt>
add    $0x1,%rbx
mov    -0x30(%rbp),%rcx
add    $0xffffffffffffffff,%rcx
cmp    %rcx,%rbx
jl     1200 <main+0xd0>
lea    0xdd5(%rip),%rdi
jmp    1177 <main+0x47>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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