gets
ws = gets.strip.split(" ").map(&:to_i)

ans = 10001
0.upto(ws.size - 2) do |i|
  s1 = 0
  0.upto(i) do |j|
    s1 += ws[j]
  end

  s2 = 0
  (i + 1).upto(ws.size - 1) do |j|
    s2 += ws[j]
  end

  s = (s2 - s1).abs
  ans = s if s < ans
end

puts ans
