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

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

m = 100
do i = 1 , n
   if( abs( a(i) - sum(a)/n ) < m ) then
      m = abs( a(i) - sum(a)/n )
      j = i
   end if
end do
do i = 1, n
   if( i/=j ) then
      if( abs( sum(a)/n-a(i) ) ==abs( sum(a)/n - a(j)) ) then
         j = 1
      end if
   end if
end do
write(*,'(i0)') j - 1


end program main
