read N
read W
W=($W)

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

ans=100000

for ((i=0; i<$N; i++)); do
    left=${W[@]:0:$i}
    X=$(echo ${left[@]} | tr ' ' "\n" | awk '{sum+=$1} END {print sum}')
    Y=$((sum-X))
    
    V=$(echo "$X-$Y" | bc -l)
    V=${V#-}
    if [[ $V -lt $ans ]]; then
        ans=$V
    fi
done

echo $ans
