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