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

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

end program main
