fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val x = readLine()?.split(" ")?.map(String::toInt) ?: return

    val min = x.min() ?: return
    val max = x.max() ?: return

    val total = min.until(max + 1).map { p ->
        x.sumBy {
            Math.pow((it - p).toDouble(), 2.0).toInt()
        }
    }.min() ?: return
    println(total)
}