program gcd_main
  implicit none
 
  integer(8) :: n, i, j, k, mk, sumb, paia, waru,mkb
  integer(8),allocatable,dimension(:) :: A
 
  read(*,*) n
  allocate(A(n))
!  allocate(b(n))
  read(*,*) (A(j), j=1,n)
 
  mk=A(1)
  paia=A(1)
  do i=2,n
     mk = gcd(mk, A(i))
     paia=paia*A(i)
  enddo
  
  paia=paia/(mk**n)
  print *, 'paia=',paia
  sumb=0
  A(1)=paia*mk/A(1)
  mkb=A(1)
  sumb=A(1)
  do i=2,n
     sumb=sumb+paia*mk/A(i)
     A(i)=paia*mk/A(i)
     print *, mkb, A(i)
     mkb = gcd(mkb, A(i))
  enddo
 
  
  waru=10**9+7
  
  print *, mod(sumb/mkb,waru), sumb,mkb
  
  stop
contains
  ! 最大公約数計算
  !
  ! :param  integer a
  ! :param  integer b
  ! :return integer gcc
  integer(8) function gcd(a, b)
    implicit none
    integer(8), intent(IN) :: 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 gcd_main
