import scala.io.StdIn._

object Main extends App {


  val n = readInt()
  val X = readLine().split(" ").map(_.toInt)

  def solve() = {
    (X.min to X.max).foldLeft(Long.MaxValue) { (minConsumption, p) =>
      val consumption = X.foldLeft(0) { (acc, x) =>
        acc + (x-p) * (x-p)
      }
      Math.min(minConsumption, consumption)
    }
  }

  println(solve())

}

