"""Boot-camp-for-Beginners_002_C_Rally_19-August-2020.py"""
import numpy as np
import sys

N=int(input())
X = list(map(int,input().split()))
s=0
for i in range(len(X)):
    s+=X[i]
P=int(s/N)

Sum_round_down=0
Sum_round_up=0
for i in range(len(X)):
    Sum_round_down+=(P-X[i])**2
    Sum_round_up+=(P+1-X[i])**2
if(Sum_round_down>=Sum_round_up):
    Sum=Sum_round_up
else:
    Sum=Sum=Sum_round_down
print(int(Sum)) """Boot-camp-for-Beginners_002_C_Rally_19-August-2020.py""" import numpy as np numpy import sys sys N=int(input()) N int(input()) int input() input X = list(map(int,input().split())) X list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split s=0 s 0 for i in range(len(X)):
    s+=X[i] i range(len(X)) range len(X) len X s+=X[i] s X[i] X i P=int(s/N) P int(s/N) int s/N s N Sum_round_down=0 Sum_round_down 0 Sum_round_up=0 Sum_round_up 0 for i in range(len(X)):
    Sum_round_down+=(P-X[i])**2
    Sum_round_up+=(P+1-X[i])**2 i range(len(X)) range len(X) len X Sum_round_down+=(P-X[i])**2 Sum_round_down (P-X[i])**2 P-X[i] P X[i] X i 2 Sum_round_up+=(P+1-X[i])**2 Sum_round_up (P+1-X[i])**2 P+1-X[i] P+1 P 1 X[i] X i 2 if(Sum_round_down>=Sum_round_up):
    Sum=Sum_round_up
else:
    Sum=Sum=Sum_round_down Sum_round_down>=Sum_round_up Sum_round_down Sum_round_up Sum=Sum_round_up Sum Sum_round_up Sum=Sum=Sum_round_down Sum Sum_round_down =Sum=Sum_round_down Sum Sum_round_down print(int(Sum)) print int(Sum) int Sum s+=X[i] X[i] s Sum=Sum=Sum_round_down Sum_round_down Sum Sum_round_up=0 0 Sum_round_up Sum_round_down=0 0 Sum_round_down P=int(s/N) int(s/N) P Sum_round_down+=(P-X[i])**2 (P-X[i])**2 Sum_round_down Sum=Sum_round_down Sum_round_down Sum Sum=Sum_round_up Sum_round_up Sum X = list(map(int,input().split())) list(map(int,input().split())) X s=0 0 s Sum_round_up+=(P+1-X[i])**2 (P+1-X[i])**2 Sum_round_up N=int(input()) int(input()) N
"""Boot-camp-for-Beginners_002_C_Rally_19-August-2020.py"""
import numpy as np
import sys

N=int(input())
X = list(map(int,input().split()))
s=0
for i in range(len(X)):
    s+=X[i]
P=int(s/N)

Sum_round_down=0
Sum_round_up=0
for i in range(len(X)):
    Sum_round_down+=(P-X[i])**2
    Sum_round_up+=(P+1-X[i])**2
if(Sum_round_down>=Sum_round_up):
    Sum=Sum_round_up
else:
    Sum=Sum=Sum_round_down
print(int(Sum))