function Main(input) {
  input = input.split("\n");
  const peopleNum = input[0]
  const harfPosition = Math.ceil(peopleNum / 2)
  const dimentions = input[1].split(" ");
  dimentions.sort((a, b) => a - b)
  var p
  const hp = []
  if(peopleNum%2) {
    p = dimentions[harfPosition]
  } else {
    p = (dimentions[harfPosition -1] + dimentions[harfPosition])/2
  }
  for(var i = 0; i < peopleNum; i++) {
	hp.push(Math.pow((dimentions[i] - p), 2))
  }
  const result = hp.reduce((accumulator, currentValue) => accumulator + currentValue)
  console.log(result)
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));