#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() {
  int t;
  long long int res, n, ele, i;
  scanf("%d", &t);
  while (t--) {
    scanf("%lld %lld", &n, &res);
    for (i = 1; i < n; i++) {
      scanf("%lld", &ele);
      res = gcd(res, ele);
    }
    printf("%lld\n", res);
  }
  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     11da <main+0xaa>
lea    0xe97(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movq   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    11c5 <main+0x95>
lea    0xe70(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <gcd@plt>
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1183 <main+0x53>
mov    -0x10(%rbp),%rsi
lea    0xe3d(%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   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xebb(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    1169 <main+0x39>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe93(%rip),%r14
lea    0x18(%rsp),%r12
lea    0x10(%rsp),%r15
lea    0xe87(%rip),%r13
lea    0x20(%rsp),%rbx
lea    0xe80(%rip),%rbp
jmp    11a7 <main+0x77>
nop
mov    0x10(%rsp),%rax
mov    %rbp,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
subl   $0x1,0xc(%rsp)
jb     1158 <main+0x28>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
cmpq   $0x2,0x18(%rsp)
jl     1190 <main+0x60>
mov    %r14,%rbp
mov    $0x1,%r14d
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%rdi
mov    0x20(%rsp),%rsi
call   1050 <gcd@plt>
mov    %rax,0x10(%rsp)
add    $0x1,%r14
cmp    0x18(%rsp),%r14
jl     11d0 <main+0xa0>
mov    %rbp,%r14
lea    0xe07(%rip),%rbp
jmp    1195 <main+0x65>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [10 x i8] c"%lld %lld\00"
@.str.2 = [5 x i8] c"%lld\00"
@.str.3 = [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
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %8
8: ; preds = %26, %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 %29
12: ; preds = %8
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64* %4, i64* %3)
store i64 1, i64* %6
br label %14
14: ; preds = %23, %12
%15 = load i64, i64* %6
%16 = load i64, i64* %4
%17 = icmp slt i64 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64* %5)
%20 = load i64, i64* %3
%21 = load i64, i64* %5
%22 = call i64 @gcd(i64 %20, i64 %21)
store i64 %22, i64* %3
br label %23
23: ; preds = %18
%24 = load i64, i64* %6
%25 = add nsw i64 %24, 1
store i64 %25, i64* %6
br label %14
26: ; preds = %14
%27 = load i64, i64* %3
%28 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %27)
br label %8
29: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [10 x i8] c"%lld %lld\00"
@.str.2 = [5 x i8] c"%lld\00"
@.str.3 = [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 = bitcast i64* %2 to i8*
%7 = bitcast i64* %3 to i8*
%8 = bitcast i64* %4 to i8*
%9 = call i32 (i8*, ...) @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 %34, label %13
13: ; preds = %0, %28
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64* %3, i64* %2)
%15 = load i64, i64* %3
%16 = icmp sgt i64 %15, 1
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = load i64, i64* %2
br label %28
19: ; preds = %13, %19
%20 = phi i64 [ %25, %19 ], [ 1, %13 ]
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64* %4)
%22 = load i64, i64* %2
%23 = load i64, i64* %4
%24 = call i64 @gcd(i64 %22, i64 %23)
store i64 %24, i64* %2
%25 = add nuw nsw i64 %20, 1
%26 = load i64, i64* %3
%27 = icmp slt i64 %25, %26
br i1 %27, label %19, label %28
28: ; preds = %19, %17
%29 = phi i64 [ %18, %17 ], [ %24, %19 ]
%30 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %29)
%31 = load i32, i32* %1
%32 = add nsw i32 %31, -1
store i32 %32, i32* %1
%33 = icmp eq i32 %31, 0
br i1 %33, label %34, label %13
34: ; preds = %28, %0
ret i32 0
}