#!/usr/local/gnu/bin/bash
read n
x=(`sort -n`)
m=1000000000
for p in `seq ${x[0]} ${x[n-1]}`
do
    d=0
    for i in ${x[@]}
    do
        d=$((d+(i-p)*(i-p)))
    done
    ((d<m)) && m=$d
done
echo $m
