import sys
n=int(input())
x=list(map(int,input().split()))

if n==1:
    print('0')
    sys.exit()

if x.count(x[0])==n:
    print('0')
    sys.exit()

a=sum(x)/len(x)
d=[]
for i in range(min(x),max(x)):
    c=0
    for j in x:
        c+=(i-j)**2
    d.append(c)

print(min(d)) 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 if n==1:
    print('0')
    sys.exit() n==1 n 1 print('0') print '0' sys.exit() sys.exit sys exit if x.count(x[0])==n:
    print('0')
    sys.exit() x.count(x[0])==n x.count(x[0]) x.count x count x[0] x 0 n print('0') print '0' sys.exit() sys.exit sys exit a=sum(x)/len(x) a sum(x)/len(x) sum(x) sum x len(x) len x d=[] d [] for i in range(min(x),max(x)):
    c=0
    for j in x:
        c+=(i-j)**2
    d.append(c) i range(min(x),max(x)) range min(x) min x max(x) max x c=0 c 0 for j in x:
        c+=(i-j)**2
     j x c+=(i-j)**2 c (i-j)**2 i-j i j 2 d.append(c) d.append d append c print(min(d)) print min(d) min d c=0 0 c a=sum(x)/len(x) sum(x)/len(x) a n=int(input()) int(input()) n c+=(i-j)**2 (i-j)**2 c x=list(map(int,input().split())) list(map(int,input().split())) x d=[] [] d
import sys
n=int(input())
x=list(map(int,input().split()))

if n==1:
    print('0')
    sys.exit()

if x.count(x[0])==n:
    print('0')
    sys.exit()

a=sum(x)/len(x)
d=[]
for i in range(min(x),max(x)):
    c=0
    for j in x:
        c+=(i-j)**2
    d.append(c)

print(min(d))
