program gem
  implicit none
  integer :: n, i
  integer(8) :: a(100), m, b(0:100)
  a = 0_8
  b = 0_8
  read(*,*) n
  read(*,*) a(1:n)
  m = sum(a(1:n))
  do i = 1, n
    b(i) = sum(a(i:n:i))
  end do
  write(*,'(i0)') m-minval(b(0:n))
  stop
end program gem