fun main (arg: Array<String>){
	var N = readLine()!!.toInt()
	var list = readLine()!!.split(" ").map(String::toInt)
	var linear:Double = 0.0
	for(l in list){
		linear = linear + (2 * l)
	}
	var position = Math.round(linear / (2*N))
	
	var result = 0
	for(i in list){
		result  = result + ((i - position)*(i - position)).toInt()
	}
	println(result)
}