'use strict'
const main = arg => {
  const n = parseInt(arg.split('\n')[0], 10)
  const xn = arg
    .split('\n')[1]
    .split(' ')
    .map(e => parseInt(e, 10))
  const avg = Math.round(xn.reduce((val, e) => val + e, 0) / n)
  const w = xn.reduce((v, e) => v + (e - avg) * (e - avg), 0)
  console.log(w)
}
main(require('fs').readFileSync('/dev/stdin', 'utf-8'))
