function Main(input){
  line = input.split('\n');
  N = parseInt(line[0].trim());
  W = line[1].trim().split(' ').map(n => parseInt(n));
  min = Math.abs(sum(W, 0, 1) - sum(W, 1, N));
  for (T = 2; T < N; T++) {
    diff = Math.abs(sum(W, 0, T) - sum(W, T, N));
    min = diff < min ? diff : min;
  }
  console.log(min);
}

function sum(A, B, C) {
  total = 0;
  for (i = B; i < C; i++) {
    total += A[i];
  }
  return total;
}
 
Main(require("fs").readFileSync("/dev/stdin","utf-8"));
