import kotlin.math.min

fun main() {
    val n = readLine()!!.toInt()
    val xN = readLine()!!.split(" ").map { it.toInt() }
    val sumTotal = xN.sum()
    
    var ans1 = 0
    var ans2 = 0
    for (i in 0..(n-1)) {
        val t1 = (sumTotal + n - 1) / n - xN[i]
        val t2 = sumTotal / n - xN[i]
        ans1 += t1 * t1
        ans2 += t2 * t2
    }
    val answer = min(ans1, ans2)
    println("$answer")
}