import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt()
  val xs = List.fill(n)(sc.nextInt)

  var minHp = Int.MaxValue
  for (p <- xs.min to xs.max) {
    val hp = xs.foldLeft(0)((z, x) => z + Math.pow(x - p, 2).toInt)
    if (hp < minHp) {
      minHp = hp
    }
  }
  println(minHp)
}
