function Main(input) {
	var list = input.split("\n")[1].split(" ").map((list)=>Number(list));
  var max = 0;
  for(var i = 0; i < list.length; i++){
    max += list[i];
  }
  
  var output = 10001;
  var ruiseki = 0;
  for(var i = 0; i < list.length - 1; i++){
    ruiseki += list[i];
    max -= list[i];
    output = Math.min(output,Math.abs(max - ruiseki));
  }
  console.log(output);
  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
