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

xmin = x[0]
xmax = x[-1]
ans = 10**9
for i in range(xmin, xmax+1):
    d = 0
    for j in x:
        d += (j - i)**2
    ans = min(ans, d)
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 xmin = x[0] xmin x[0] x 0 xmax = x[-1] xmax x[-1] x -1 ans = 10**9 ans 10**9 10 9 for i in range(xmin, xmax+1):
    d = 0
    for j in x:
        d += (j - i)**2
    ans = min(ans, d) i range(xmin, xmax+1) range xmin xmax+1 xmax 1 d = 0 d 0 for j in x:
        d += (j - i)**2
     j x d += (j - i)**2 d (j - i)**2 j - i j i 2 ans = min(ans, d) ans min(ans, d) min ans d print(ans) print ans d = 0 0 d d += (j - i)**2 (j - i)**2 d xmin = x[0] x[0] xmin x = list(map(int,input().split())) list(map(int,input().split())) x xmax = x[-1] x[-1] xmax ans = 10**9 10**9 ans n = int(input()) int(input()) n ans = min(ans, d) min(ans, d) ans
n = int(input())
x = list(map(int,input().split()))
x.sort()

xmin = x[0]
xmax = x[-1]
ans = 10**9
for i in range(xmin, xmax+1):
    d = 0
    for j in x:
        d += (j - i)**2
    ans = min(ans, d)
print(ans)