import java.util.Arrays;
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextInt()
    val X = IntArray(N)
    var sum = 0
    
    for (i in X.indices) {
      X[i] = input.nextInt()
      sum += X[i]
    }
    
    val p1 = sum / N
    var stamina1 = 0
      
    for (i in X.indices) {
      val dist = X[i] - p1
      stamina1 += dist * dist
    }
    
    val p2 = p1 + 1
    var stamina2 = 0
      
    for (i in X.indices) {
      val dist = X[i] - p2
      stamina2 += dist * dist
    }
    
    val stamina = Math.min(stamina1, stamina2)
    
    println(stamina)
  } 
}