fun main(args:Array<String>){
  var n = readLine()!!.toInt()
  var w = readLine()!!.split(" ").map(String::toInt).toList()
  var all = 0
  var ans = 0
  var hoge = 0
  var abs = 0
  var num = 1000
  var t = 0
  for(i in 0..n-1){
    all += w[i]
  }
  for(i in 0..n-1){
    ans += w[i]
    hoge = all-ans
    abs = Math.abs(ans-hoge)
    if(abs<=num){
      num = abs
    }
  }
  println(num)
}