N=int(input())
X=list(map(int,input().split()))
X.sort()

ans=10**1000
for p in range(X[0],X[-1]+1):
    tmp=0
    for x in X:
        tmp+=(x-p)**2
    ans=min(ans,tmp)
print(ans) 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 X.sort() X.sort X sort ans=10**1000 ans 10**1000 10 1000 for p in range(X[0],X[-1]+1):
    tmp=0
    for x in X:
        tmp+=(x-p)**2
    ans=min(ans,tmp) p range(X[0],X[-1]+1) range X[0] X 0 X[-1]+1 X[-1] X -1 1 tmp=0 tmp 0 for x in X:
        tmp+=(x-p)**2
     x X tmp+=(x-p)**2 tmp (x-p)**2 x-p x p 2 ans=min(ans,tmp) ans min(ans,tmp) min ans tmp print(ans) print ans tmp+=(x-p)**2 (x-p)**2 tmp tmp=0 0 tmp X=list(map(int,input().split())) list(map(int,input().split())) X ans=10**1000 10**1000 ans N=int(input()) int(input()) N ans=min(ans,tmp) min(ans,tmp) ans
N=int(input())
X=list(map(int,input().split()))
X.sort()

ans=10**1000
for p in range(X[0],X[-1]+1):
    tmp=0
    for x in X:
        tmp+=(x-p)**2
    ans=min(ans,tmp)
print(ans)