import java.io.PrintWriter
import java.util.StringTokenizer
import kotlin.math.pow

fun main() {

    fun PrintWriter.solve() {
        val n = nextInt()
        var x = IntArray(n){nextInt()}

        var poss = x.sum()/n

        var v1 = x.map { (it - poss).toDouble().pow(2) }.sum()
        var v2 = x.map { (it - poss -1 ).toDouble().pow(2) }.sum()


        println(minOf(v1,v2).toInt())



    }

    writer.solve()
    writer.flush()


}


private val reader = System.`in`.bufferedReader()
private val writer = PrintWriter(System.out, false)

private var tokenizer: StringTokenizer = StringTokenizer("")

private fun next(): String {
    while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())
    return tokenizer.nextToken()
}

private fun nextInt() = next().toInt()
private fun nextLong() = next().toLong()
private fun nextDouble() = next().toDouble()
private fun nextLine() = reader.readLine()

