import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val x = (1..n).map {
        sc.nextInt()
    }

    println(abc156c(n, x))
}

private fun abc156c(n: Int, x: List<Int>): Int {
    val p = x.sum() / n

    val a = x.map { calc(it, p) }.sum()
    val b = x.map { calc(it, p + 1) }.sum()
    
    return Math.min(a, b)
}

private fun calc(xi: Int, p: Int): Int {
    var temp = xi - p
    return Math.pow(temp.toDouble(), 2.0).toInt()
}