process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line)
});

reader.on('close', () => {

  var n = lines[0]
  var w = [...lines[1].split(' ')]
  for (var k in w) w[k] = parseInt(w[k])

  var math = (ary, t) => {
    var b = ary.slice(0,t)
    var a = ary.slice(t)
    var sum = {
      b: 0,
      a: 0
    }
    for (var v of b) sum.b += v
    for (var v of a) sum.a += v
    return Math.abs(sum.b - sum.a)
  }

  var r = []
  for (var i=1;i<w.length;i++) {
    r.push(math(w, i))
  }

  console.log(Math.min(...r))

});
