program main
  implicit none
  integer :: n, res, i
  integer, allocatable :: a(:)

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

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

  write (*, "(i0)") res

  contains

  function gcd(x, y) result(a)
    integer, intent(in) :: x, y
    integer :: a, b, r
    a = max(x, y)
    b = min(x, y)
    do while (b > 0)
      r = mod(a, b)
      a = b
      b = r
    end do
  end function gcd
end program main
