#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 long gcd(long long, long long);
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  int t;
  scanf("%d", &t);
  while (t--) {
    long long int n;
    scanf("%lld", &n);
    long long int a;
    scanf("%lld", &a);
    if (n == 1) {
      printf("%lld\n", a);
      continue;
    }
    while (--n) {
      long long int b;
      scanf("%lld", &b);
      a = a < b ? gcd(a, b) : gcd(b, a);
    }
    printf("%lld\n", a);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     122d <main+0xfd>
lea    0xe97(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe85(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpq   $0x1,-0x10(%rbp)
jne    11a9 <main+0x79>
mov    -0x18(%rbp),%rsi
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
jmp    1151 <main+0x21>
jmp    11ae <main+0x7e>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1218 <main+0xe8>
lea    0xe38(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    11fa <main+0xca>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <gcd@plt>
mov    %rax,-0x28(%rbp)
jmp    120b <main+0xdb>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <gcd@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    11ae <main+0x7e>
mov    -0x18(%rbp),%rsi
lea    0xde5(%rip),%rdi
call   1030 <printf@plt>
jmp    1151 <main+0x21>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0x4(%rsp)
jae    1167 <main+0x37>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe95(%rip),%rbx
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%r15
lea    0xe89(%rip),%r12
lea    0x18(%rsp),%r13
jmp    11a7 <main+0x77>
cs nopw 0x0(%rax,%rax,1)
mov    0x8(%rsp),%rax
mov    %r12,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
subl   $0x1,0x4(%rsp)
jb     1157 <main+0x27>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%rax
cmp    $0x1,%rax
je     1190 <main+0x60>
add    $0xffffffffffffffff,%rax
mov    %rax,0x10(%rsp)
jmp    11f5 <main+0xc5>
nopw   0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1050 <gcd@plt>
mov    %rax,0x8(%rsp)
addq   $0xffffffffffffffff,0x10(%rsp)
je     1195 <main+0x65>
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x8(%rsp),%rsi
mov    0x18(%rsp),%rax
cmp    %rax,%rsi
jge    11e0 <main+0xb0>
mov    %rsi,%rdi
mov    %rax,%rsi
jmp    11e3 <main+0xb3>

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

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