read N
read W

sum=$(echo $W | tr ' ' '\n' | awk '{sum+=$1} END {print sum}')

acc=0
ans=1000000

for i in $(seq 1 $N)
do
    acc=$(($acc+$(echo $W | cut -d ' ' -f $i)))
    rest=$(($sum-$acc))
    if [ $acc -gt $rest ]; then
        V=$(($acc-$rest))
    else
        V=$(($rest-$acc))
    fi
    if [ $V -lt $ans ]; then
        ans=$V
    fi
done

echo $ans