function plus (a, b) {
  return a + b;
}

function main (input) {
  const list = input.split('\n');
  const N = list[0] * 1;
  const W = list[1].split(' ').map(v => v * 1);
 
  var nArr = new Array(N).fill(0); 
  const abs = nArr.reduce((arr, val , i) => {
    const Ni = i + 1;
    const S1 = W.slice(0, Ni + 1).reduce(plus, 0);
    const S2 = W.slice(Ni + 1).reduce(plus, 0);
    const a = Math.abs(S1 - S2)
    arr.push(a);
    return arr;
  }, []);
  
  console.log(Math.min.apply(null, abs));
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));