import java.util.*
import kotlin.comparisons.*

fun main(args : Array<String>) {
  val n = readLine()!!.toInt()
  val w = readLine()!!.split(' ').map(String::toInt)
  val s = IntArray(n)
  s[0] = w[0]
  for (i in 1 until n) {
    s[i] = s[i - 1] + w[i]
  }
  var ans = Int.MAX_VALUE
  for (i in 0..n - 2) {
    val s1 = s[i]
    val s2 = s[n - 1] - s[i]
    ans = Math.min(ans, Math.abs(s1 - s2))
  }
  println(ans)
}
