fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val XS = readLine()!!.split(" ").map(String::toInt)
    val P = XS.average()

    var min = Int.MAX_VALUE

    val floor = Math.floor(P).toInt()
    val ceil = Math.ceil(P).toInt()

    min = Math.min(XS.map { (it - floor) * (it - floor) }.sum(), min)
    min = Math.min(XS.map { (it - ceil) * (it - ceil) }.sum(), min)

    println(min)
}



