'use strict'

function Main(input) {
  const N = Number(input.split("\n")[0])
  const W = input.split("\n")[1].split(" ").map(x => Number(x))
  const list = []

  const total = W.reduce((acc, x) => acc + x)

  for(let i=1; i<N; i++) {
      let before = 0
      for(let j=0; j<i; j++) {
          before += W[j]
      }
      let after = total - before
      list.push(Math.abs(before - after))
  }
  console.log(Math.min.apply(null, list))
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim())
