function Main(input) {
  var chars = input.split('\n');

  var kireme = Math.floor(chars[0]);
  var kukan = chars[1].split(' ');
  
  var kukanInt = kukan.map(n => parseInt(n, 10));
  var mokuhyo = 0;
  
  if (kireme % 2 === 0) {
    var kukan1 = kukanInt.splice(0, kukanInt.length / 2);
    mokuhyo = kukan1.reduce((x, y) => x + y);
    mokuhyo2 = kukanInt.reduce((x, y) => x + y);
  
    console.log(mokuhyo2 - mokuhyo);
  } else {
    var kukan1 = kukanInt.splice(0, Math.ceil(kukanInt.length / 2));
    mokuhyo = kukan1.reduce((x, y) => x + y);
    mokuhyo2 = kukanInt.reduce((x, y) => x + y);
  
    console.log(Math.abs(mokuhyo2 - mokuhyo));
  }
  
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));