import java.util.*

object MainKt {
	@JvmStatic
	fun main(args: Array<String>) {
		val scanner = Scanner(System.`in`)
		val n = scanner.nextInt()
		var ws = IntArray(n)
		var sum = 0
		for (i in 0..n-1) {
			ws[i]=scanner.nextInt()
			sum+=ws[i]
		}
		var s1 = 0
		var d = Integer.MAX_VALUE
		for (i in 0..n-1){
			s1+=ws[i]
			if (s1<=sum/2){
				d = sum-(2*s1)
			}else {
				d = Math.min(d,2*s1-sum)
				break
			}
		}
		println(d)
	}
}