program greedy_customers
  implicit none
  integer :: n, a(100000), x, i, k
  integer(8) :: m
  logical :: ok
  a = 0
  read(*,*) n
  do i = 1, n
    read(*,*) a(i)
  end do
  x = maxval(a(1:n))
  m = int(a(1)-1,8)
  do k = 2, x
    ok = .true.
    do i = 1, n
      if (a(i).lt.k) cycle
      ok = .false.
      if (a(i).eq.k) exit
      m = m+int((a(i)-1)/k,8)
      a(i) = mod(a(i)-1,k)+1
    end do
    if (ok) exit
  end do
  write(*,'(i0)') m-1_8
  stop
end program greedy_customers