fun main(args: Array<String>) {
    //val people_count = 7
    //val coordinates = arrayOf(14, 14, 2, 13, 56, 2, 37)
    val people_count = readLine()!!.toInt()
    val coordinates = readLine()!!.split(" ").map { it.toInt() }

    val answer = (coordinates.min()!!..coordinates.max()!!).map { temp_p ->
        coordinates.map { (it - temp_p) * (it - temp_p) }.sum()
    }.min()

    println("$answer")
}
