object Main extends App {
	val sc = new java.util.Scanner(System.in)
	val pw = new java.io.PrintWriter(System.out)
	
	val n = sc.nextInt
	val x = Seq.fill(n)(sc.nextInt)
	
	val a = x.sum / n
	
	def f(p: Int): Int = x.map(xi => (xi - p) * (xi - p)).sum

	pw.println(Math.min(f(a), f(a+1)))
	pw.flush()
}