program thumbnail
  implicit none
  integer :: n, a(100) = 0, i, s, d = 1e9, x
  read(*,*) n
  read(*,*) a(1:n)
  s = sum(a(1:n))
  do i = 1, n
    if (d > abs(s-n*a(i))) then
      d = abs(s-n*a(i))
      x = i-1
    end if
  end do
  write(*,'(i0)') x
end program thumbnail