

function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var W = input[1].split(" ").map(i => parseInt(i));
  var ans=100000000;
  var sum1=0;
  var sum2=0;
  for(var i=0;i<N;i++){
    sum1+=W[i];
  }
  for(var i=0;i<N;i++){
    sum2+=W[i];
    ans=Math.min(ans,Math.abs(sum2-(sum1-sum2)));
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));