program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n, ans, i
    integer(int32), allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)

    ans=a(1)
    do i = 2, n
        ans = gcd(ans,a(i))
    end do
    print'(i0)', ans

contains
recursive function gcd(x,y) result(ret)
    integer(int32):: x,y,ret

    if (mod(x,y) == 0) then
        ret = y
        return
    end if

    ret = gcd(y,mod(x,y))
end function
end program name