read n
read -a a
s=$((`echo ${a[@]} | tr ' ' '+'`))
md=$((s>a[0]*n?s-a[0]*n:a[0]*n-s))
mi=0
for i in `seq $((n-1))`
do
    v=${a[i]}
    d=$((s>v*n?s-v*n:v*n-s))
    if((d<md))
    then
        md=$d
        mi=$i
    fi
done
echo $mi
