import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val x = readLine.split(" ").map(_.toInt)
  var min = Int.MaxValue
  for (i <- x.min to x.max) {
    val h = x.foldLeft(0) { (acc, v) =>
      acc + math.pow(v - i, 2).toInt
    }
    min = math.min(min, h)
  }
  println(min)
}
