'use strict';

function main(stdin) {
  const input = stdin.split('\n');
  const N = Number(input.shift());
  const W = input[0].split(' ').map(v => parseInt(v, 10));

  let S2 = W.reduce((a, b) => a + b);
  let S1 = 0;
  const diff = [];

  for (let T = 0; T < N - 1; ++T) {
    S1 += W[T];
    S2 -= W[T];
    diff[T] = Math.abs(S1 - S2);
  }

  const min = diff.reduce((a, b) => Math.min(a, b));
  
  console.log(diff, min);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));