function Main(input) {
  var tmp = input.trim().split('\n')
  var N = parseInt(tmp[0])
  var Xarr = tmp[1].split(' ')

  var Xsum = 0
  for (var i = 0; i < Xarr.length; i++) {
    Xsum += parseInt(Xarr[i])
  }

  var avg = Math.floor(Xsum / N)

  var tmp = []
  for (var j = avg - 25; j <= avg + 25; j++) {
    var sum = 0
    for (var i = 0; i < Xarr.length; i++) {
      sum = sum + Math.abs(Math.pow(j - parseInt(Xarr[i]), 2))
    }
    tmp.push(sum)
  }

  var result = Math.min.apply(null, tmp)

  console.log(result)
  return result
}

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