fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val xx = readLine()!!.split(" ").map { it.toInt() }.sorted()

    var min = Int.MAX_VALUE
    for (i in xx.first()..xx.last()) {
        var sum = 0
        xx.forEach {
            sum += (it - i) * (it - i)
        }

        min = Math.min(sum, min)
    }

    println(min)
}