n=gets.to_i
w=gets.split.map &:to_i
min=1000000
suma,sumb=0,0
(1..n).each do |i|
  (0..i-1).each do |j|
    suma+=w[j]
  end
  (i..n-1).each do |k|
    sumb+=w[k]
  end
  min=[(suma-sumb).abs,min].min
  suma,sumb=0,0
end
puts min
