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

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

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


end program main
