function Main (input) {
  var N, X;
  var ans1 = [];
  input = input.split("\n");
  N = parseInt(input[0], 10);
  X = input[1].split(" ").map(inp => parseInt(inp, 10));
  for (var i = Math.min(...X); i <= Math.max(...X); i++) {
    var ret = 0;
    for (var j of X) {
      ret += Math.pow(i - j, 2);
    }
    ans1.push(ret);
  }
  console.log(Math.min(...ans1));
}

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