n = int(eval(input()))

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

A.sort()

while len(A) > 1:

  a = [A[0]]

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

    if A[i]%A[0] == 0: continue

    else: a.append(A[i]%A[0])

  A = sorted(a)

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

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



while len(A) > 1:

    A = sorted([i%A[0] for i in A if i%A[0]!=0] + [A[0]])

print((A[0]))
n = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
while len(A) > 1:
    a = [A[0]]
    for i in range(1, len(A)):
        if A[i] % A[0] == 0:
            continue
        else:
            a.append(A[i] % A[0])
    A = sorted(a)
print((A[0]))

n = int(eval(input()))
A = sorted(list(map(int, input().split())))
while len(A) > 1:
    A = sorted([i % A[0] for i in A if i % A[0] != 0] + [A[0]])
print((A[0]))

-A = list(map(int, input().split())) -A.sort() +A = sorted(list(map(int, input().split()))) -    a = [A[0]] -    for i in range(1, len(A)): -        if A[i] % A[0] == 0: -            continue -        else: -            a.append(A[i] % A[0]) -    A = sorted(a) +    A = sorted([i % A[0] for i in A if i % A[0] != 0] + [A[0]])