"use strict"

const fs = require("fs");

function main(input) {
  const tmp = input.split("\n");
  const n = tmp[0];
  const xs = tmp[1].split(" ").map(v => parseInt(v));
  console.log(process(n, xs));
}

function process(n, xs) {
  let ret = 100000000;
  const min = Math.min(...xs);
  const max = Math.max(...xs);
  for (let p = min; p <= max; ++p) {
    const sum = xs.reduce((a, c) => a + Math.pow((c - p), 2), 0);
    if (ret > sum)
      ret = sum;
  }
  return ret;
}

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