let n = Int(readLine()!)!

let w = readLine()!.split(separator: " ").map { Int($0)! }

var sum = w.reduce(0, +)

var ans = Int.max

var curSum = 0
for i in 0..<w.count {
  ans = min(ans, abs(2 * curSum - sum))
  curSum += w[i]
}
print(ans)