import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val wl = Vector.fill(n)(sc.nextInt)
  val s  = wl.sum

  val res = (1 until n).map{i =>
    val si = wl.take(i).sum
    Math.abs(si - (s - si))
  }.min

  println(res)

}