'use strict'

function Main(input) {
  input = input.trim().split('\n')
  const N = parseInt(input[0])
  let X = input[1].split(' ').map(s => parseInt(s))

  X = X.sort()


  const memo = {}
  for(let i = 1; i <= X[X.length - 1]; ++i) {
    memo[i] = false
    for(let j = 0; j < N; ++j) {
      if (i === X[j]) memo[i] = true
    }

  }

  let result = Infinity

  for(let i = 1; i <= X[X.length - 1]; ++i) {
    if(!memo[i]) {
      let total = 0
      for(let j = 0; j < N; ++j) {
        const n = i - X[j]
        total += n * n
        // console.log(i, X[j], n, total)
      }

      result = Math.min(result, total)

    }
  }


  console.log(result)


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