program name
    implicit none
    integer(4):: n, ans,i
    integer(4),allocatable:: a(:)

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

    ans = a(1)

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

    print*, ans

contains

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

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

    ret = gcd(y,mod(x,y))

end function

end program name