object Main {
  def main(args: Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val list = List.fill(n)(sc.nextInt)
    sc.close()

    val result =
      (1 to n).map(i => Math.abs(list.take(i).sum - list.drop(i).sum)).min
    println(result)
  }
}