N=int(input())
X=list(map(int,input().split()))
l=len(X)
s=10**10
for i in range(min(X),max(X)+1):
    x=[]
    for j in range(l):
        x.append((X[j]-i)**2)
    if s>sum(x):
        s=sum(x)
print(s) 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 l=len(X) l len(X) len X s=10**10 s 10**10 10 10 for i in range(min(X),max(X)+1):
    x=[]
    for j in range(l):
        x.append((X[j]-i)**2)
    if s>sum(x):
        s=sum(x) i range(min(X),max(X)+1) range min(X) min X max(X)+1 max(X) max X 1 x=[] x [] for j in range(l):
        x.append((X[j]-i)**2)
     j range(l) range l x.append((X[j]-i)**2) x.append x append (X[j]-i)**2 X[j]-i X[j] X j i 2 if s>sum(x):
        s=sum(x) s>sum(x) s sum(x) sum x s=sum(x) s sum(x) sum x print(s) print s x=[] [] x X=list(map(int,input().split())) list(map(int,input().split())) X l=len(X) len(X) l N=int(input()) int(input()) N s=sum(x) sum(x) s s=10**10 10**10 s
N=int(input())
X=list(map(int,input().split()))
l=len(X)
s=10**10
for i in range(min(X),max(X)+1):
    x=[]
    for j in range(l):
        x.append((X[j]-i)**2)
    if s>sum(x):
        s=sum(x)
print(s)