object Main extends App {
	val N = scala.io.StdIn.readInt
	val X = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	val sum1 = X.map(z => z*z).sum
	val sum2 = X.sum

	if(sum2%N == 0) println(sum1 - sum2*sum2/N)
	else{
		val p1 = sum2/N
		val p2 = (sum2 + N - 1)/N

		println(math.min(N*p1*p1 - 2 * sum2 * p1 + sum1, N*p2*p2 - 2*sum2*p2 + sum1))
	}
}