object Main extends App{
  import scala.io.StdIn._
  var a=0;var b=0
  val n=readInt()
  val x=readLine().split(" ").map(_.toInt)
  val s=x.sum/x.length
  for{i <- (0 until n)}{
    a+=(x(i)-s)*(x(i)-s)
    b+=(x(i)-(s+1))*(x(i)-(s+1))
  }
  println(Math.min(a,b))
}