program prob2
    implicit none
    integer(8) :: n
    integer(8), allocatable :: a(:)
    integer(8) :: i, ans
    
    read(*,*) n
    allocate(a(n))
    read(*,*) a

    ans = gcd(a(1), a(2))
    do i = 3, n
        ans = gcd(ans, a(i))
    end do

    write(*,*) ans

    deallocate(a)

    stop
contains


integer(8) function gcd(a, b)
    implicit none
    integer(8) :: a, b
    integer(8) :: l, m, n

    m = a
    n = b

    do
    l = mod(m, n)
    if (l == 0) exit
    m = n
    n = l
    end do

    gcd = n

    return
end function gcd

end program prob2