'use strict';
function main(input) {
  const num = Number(input.split('\n')[0]);
  const weightList = input.split('\n')[1].split(' ').map(i => Number(i));
  const distList = [];
  for (let i = 0; i < num - 1; i++) {
    distList.push(Math.abs(weightList.slice(0, i + 1).reduce((prev, current) => prev + current) - weightList.slice(i + 1).reduce((prev, current) => prev + current)));
  }
  console.log(Math.min(...distList));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));