from collections import deque
N = int(input())
A = list(map(int, input().split()))

A.sort()
A = deque(A)
while len(A) > 1:
  s = []
  for i in range(len(A)-1):
    div = A[-1] % A[0]
    A.pop()
    if div != 0:
      s.append(div)
  s.append(A[0])
  s.sort()
  A = deque(s)
print(*A) from collections import deque N = int(input()) N int(input()) int input() input A = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split A.sort() A.sort A sort A = deque(A) A deque(A) deque A while len(A) > 1:
  s = []
  for i in range(len(A)-1):
    div = A[-1] % A[0]
    A.pop()
    if div != 0:
      s.append(div)
  s.append(A[0])
  s.sort()
  A = deque(s) len(A) > 1 len(A) len A 1 s = [] s [] for i in range(len(A)-1):
    div = A[-1] % A[0]
    A.pop()
    if div != 0:
      s.append(div)
   i range(len(A)-1) range len(A)-1 len(A) len A 1 div = A[-1] % A[0] div A[-1] % A[0] A[-1] A -1 A[0] A 0 A.pop() A.pop A pop if div != 0:
      s.append(div)
   div != 0 div 0 s.append(div) s.append s append div s.append(A[0]) s.append s append A[0] A 0 s.sort() s.sort s sort A = deque(s) A deque(s) deque s print(*A) print *A A s = [] [] s N = int(input()) int(input()) N A = list(map(int, input().split())) list(map(int, input().split())) A A = deque(A) deque(A) A div = A[-1] % A[0] A[-1] % A[0] div A = deque(s) deque(s) A
from collections import deque
N = int(input())
A = list(map(int, input().split()))

A.sort()
A = deque(A)
while len(A) > 1:
  s = []
  for i in range(len(A)-1):
    div = A[-1] % A[0]
    A.pop()
    if div != 0:
      s.append(div)
  s.append(A[0])
  s.sort()
  A = deque(s)
print(*A)
