program main
integer(8)::N,a,i,b,c,d
integer(8), allocatable :: j(:),k(:)
read(*, *) N
allocate(j(N))
read(*, *)(j(i), i=1,N)

a=minval(j)
c=0


k(i)=mysub(j(i),a)


d=minval(k)

print*,d

contains
function mysub(x,y)
  integer(8):: x, y
  integer(8):: m, s, h
  
  read(*,*)x,y
  ! step 1
  m = x
  s = y
  do
     ! step 2
     h=mod(m, s)
     ! step 3
     if (h == 0) then
        mysub=s
        exit
     end if
     ! step 4
     m = s
     s = h
  end do

  return
end function mysub

end program main