read N
read X
ANS=0
ANS_TMP=0
MIN=0
MAX=0
count=1

for Power in $X
do
if [ $count -eq 1 ] ;then
MIN=$Power
MAX=$Power
elif [ $Power -lt $MIN ] ;then
MIN=$Power
elif [ $Power -gt $MAX ] ;then
MAX=$Power
fi
count=$(( $count + 1 ))
done

echo $MIN
echo $MAX

while true
do
ANS_TMP=0
for Power in $X
do
ANS_TMP=$(( $(( $(( $Power - $MIN )) * $(( $Power - $MIN )) )) + $ANS_TMP ))
done

MIN=$(( $MIN + 1 ))

if [ $ANS -eq 0 ] ;then
  ANS=$ANS_TMP
elif [ $ANS_TMP -lt $ANS ] ;then
  ANS=$ANS_TMP
fi

if [ $MIN -gt $MAX ] ;then
  break
fi

done

echo $ANS

exit 0