program main
implicit none
integer :: i, k
integer :: n
integer , allocatable :: a(:)
real :: ave, j

read(*,*) n
allocate( a(n) )
read(*,*) a
ave = sum(a)/n
j = ave
do i = 1, n
   if( abs(a(i)-ave) .lt. j ) then
      j = abs(a(i)-ave)
      k = i-1
   end if
end do
write(*,'(i0)') k

end program main
