function Main(input) {
  const 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)
  let p
  const hp = []
  if(peopleNum%2) {
    p = dimentions[harfPosition]
  } else {
    p = (dimentions[harfPosition -1] + dimentions[harfPosition])/2
  }
  for(let i = 0; i < peopleNum; i++) {
	hp.push((dimentions[i] − p)**2)
  }
  const result = hp.reduse((accumulator, currentValue) => accumulator + currentValue)
  return result
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));