abs(){
    if [ $1 -lt 0 ]; then
        echo $((-$1))
    else
        echo $1
    fi
}

read N
read W

sum=0
for x in $W
do
    sum=$(($sum+$x))
done

acc=0
ans=''
for x in $W
do
    acc=$(($acc+$x))
    rest=$(($sum-$acc))
    V=$(abs $(($acc-$rest)))
    ans="$ans $V"
done

echo $ans | tr ' ' '\n' | sort -n | head -n1