import java.util.Scanner

import scala.collection.mutable.ArrayBuffer
import scala.math._

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  def solve(sc: Scanner): String = {
    val n = sc.nextInt()
    val ws = Vector.fill(n)(sc.nextInt())

    val sums = ArrayBuffer.empty[Int]
    for (i <- 1 to ws.length) {
      sums += abs(ws.slice(0, i).sum - ws.slice(i, ws.length).sum)
    }
    sums.min.toString
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}
