object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n: Int = sc.nextInt
  val pointList: List[Int] = List.fill(n)(sc.nextInt)
  def go(sum: Int, curr: Int): Int = curr match {
    case 0 => go(sum, curr + 1)
    case x if x < pointList.min => go(sum, curr + 1)
    case x if x > pointList.max => sum
    case _ => go(Math.min(sum, pointList.map(x => Math.pow(x - curr, 2)).sum.toInt), curr + 1)
  }
  println(go(Int.MaxValue, 0))
}