n = gets.to_i
ws = gets.split.map(&:to_i)

min = 1_000_000_000
1.upto(n - 1) do |i|
  l = 0
  0.upto(i) do |k|
    l += ws[k]
  end
  r = 0
  (i+1).upto(n-1) do |k|
    r += ws[k]
  end

  min = [min, (l - r).abs].min
end

p min
