#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 */
unsigned long long gcd(unsigned long long, unsigned long long);
int /*<<< orphan*/ printf(char *, unsigned long long);
int /*<<< orphan*/ scanf(char *, unsigned long long *);
int main(void) {
  unsigned long long terms, n;
  scanf("%lld", &terms);
  while (terms--) {
    scanf("%lld", &n);
    unsigned long long a[n];
    unsigned long long i;
    for (i = 0; i < n; i++) {
      scanf("%lld", a + i);
    }
    unsigned long long hcf = gcd(a[0], a[1]);
    for (i = 2; i < n; i++)
      hcf = gcd(hcf, a[i]);
    printf("%lld\n", hcf);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     1252 <main+0x122>
lea    0xe91(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11e2 <main+0xb2>
mov    -0x40(%rbp),%rsi
mov    -0x30(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe34(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11a8 <main+0x78>
mov    -0x40(%rbp),%rax
mov    (%rax),%rdi
mov    0x8(%rax),%rsi
call   1050 <gcd@plt>
mov    %rax,-0x38(%rbp)
movq   $0x2,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1236 <main+0x106>
mov    -0x40(%rbp),%rax
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <gcd@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11fe <main+0xce>
mov    -0x38(%rbp),%rsi
lea    0xdc4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
jmp    114f <main+0x1f>
mov    -0x4(%rbp),%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>
subq   $0x1,-0x38(%rbp)
jae    1169 <main+0x39>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe90(%rip),%r12
jmp    1199 <main+0x69>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe7e(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %r13,%rsp
subq   $0x1,-0x38(%rbp)
jb     1158 <main+0x28>
mov    %r12,%rdi
lea    -0x30(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rsp,%r13
mov    -0x30(%rbp),%rax
mov    %rsp,%r14
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    %r14,%rbx
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    $0x1,%r15
add    $0x8,%rbx
cmp    -0x30(%rbp),%r15
jb     11d0 <main+0xa0>
mov    (%r14),%rdi
mov    0x8(%r14),%rsi
call   1050 <gcd@plt>
cmpq   $0x3,-0x30(%rbp)
jb     1180 <main+0x50>
mov    $0x2,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rsi
mov    %rax,%rdi
call   1050 <gcd@plt>
add    $0x1,%rbx
cmp    -0x30(%rbp),%rbx
jb     1210 <main+0xe0>
jmp    1180 <main+0x50>

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

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [6 x i8] c"%lld\0A\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 ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%6 = load i64, i64* %1
%7 = add i64 %6, -1
store i64 %7, i64* %1
%8 = icmp eq i64 %6, 0
br i1 %8, label %45, label %9
9: ; preds = %0, %39
%10 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 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 ne i64 %14, 0
br label %16
16: ; preds = %9, %16
%17 = phi i64 [ %20, %16 ], [ 0, %9 ]
%18 = getelementptr inbounds i64, i64* %13, i64 %17
%19 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %18)
%20 = add nuw i64 %17, 1
%21 = load i64, i64* %2
%22 = icmp ult 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 ugt i64 %28, 2
br i1 %29, label %30, label %39
30: ; preds = %23, %30
%31 = phi i64 [ %35, %30 ], [ %27, %23 ]
%32 = phi i64 [ %36, %30 ], [ 2, %23 ]
%33 = getelementptr inbounds i64, i64* %13, i64 %32
%34 = load i64, i64* %33
%35 = call i64 @gcd(i64 %31, i64 %34)
%36 = add nuw i64 %32, 1
%37 = load i64, i64* %2
%38 = icmp ult i64 %36, %37
br i1 %38, label %30, label %39
39: ; preds = %30, %23
%40 = phi i64 [ %27, %23 ], [ %35, %30 ]
%41 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %40)
%42 = load i64, i64* %1
%43 = add i64 %42, -1
store i64 %43, i64* %1
%44 = icmp eq i64 %42, 0
br i1 %44, label %45, label %9
45: ; preds = %39, %0
ret i32 0
}