object Main extends App {
  val sc = new java.util.Scanner (System.in)
  val n = sc.nextInt
  val list = List.fill(n)(sc.nextInt)
  def power(x:Int,p:Int):Int = if(p==0) 1 else x * power(x,p-1)
  def f(p:Int):Int = list.foldLeft(0)((sum,a) => sum + power(a - p,2))
  val array = for (p <- -10 to 110) yield f(p) 
  println(array.foldLeft(100000)((seed,a) => if (a < seed) a  else  seed))
}

