import java.util.Scanner

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLine().trim().toInt()
    val xList = sc.nextLine().trim().split(' ').map { it.toInt() }

    var minCost = Integer.MAX_VALUE
    for (x in 1..100) {
        val newCost = costAtX(x, xList)
        minCost = if (newCost < minCost) newCost else minCost
    }
    println(minCost)
}

fun costAtX(x: Int, points: List<Int>): Int {
    var cost = 0
    for (point in points) {
        cost += (x - point) * (x - point)
    }
    return cost
}
