N = int(eval(input()))

A = list(map(int,input().split()))

while len(A) > 1:

    a_ = A[0]

    for x in range(1,len(A)):

        A[x] %= a_

    A = [ans for ans in A if ans > 0]

    A.sort()

print((A[0]))
N = int(eval(input()))

A = list(map(int,input().split()))

while len(A) > 1:

    A.sort()

    devided_num = int(A[0])

    devi_lis = [devided_num]

    As = A

    As.pop(0)

    A =[_%devided_num for _ in As if _%devided_num > 0]

    A += devi_lis

print((A[0]))
N = int(eval(input()))
A = list(map(int, input().split()))
while len(A) > 1:
    a_ = A[0]
    for x in range(1, len(A)):
        A[x] %= a_
    A = [ans for ans in A if ans > 0]
    A.sort()
print((A[0]))

N = int(eval(input()))
A = list(map(int, input().split()))
while len(A) > 1:
    A.sort()
    devided_num = int(A[0])
    devi_lis = [devided_num]
    As = A
    As.pop(0)
    A = [_ % devided_num for _ in As if _ % devided_num > 0]
    A += devi_lis
print((A[0]))

-    a_ = A[0] -    for x in range(1, len(A)): -        A[x] %= a_ -    A = [ans for ans in A if ans > 0] +    devided_num = int(A[0]) +    devi_lis = [devided_num] +    As = A +    As.pop(0) +    A = [_ % devided_num for _ in As if _ % devided_num > 0] +    A += devi_lis