n = int(input())
X = sorted(list(map(int,input().split())))
ans = 10**10

for i in range(X[0],X[-1]+1):
    ans = min(ans, sum((i-x)**2 for x in X))

print(ans) n = int(input()) n int(input()) int input() input X = sorted(list(map(int,input().split()))) X sorted(list(map(int,input().split()))) sorted list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ans = 10**10 ans 10**10 10 10 for i in range(X[0],X[-1]+1):
    ans = min(ans, sum((i-x)**2 for x in X)) i range(X[0],X[-1]+1) range X[0] X 0 X[-1]+1 X[-1] X -1 1 ans = min(ans, sum((i-x)**2 for x in X)) ans min(ans, sum((i-x)**2 for x in X)) min ans sum((i-x)**2 for x in X) sum (i-x)**2 i-x i x 2 print(ans) print ans ans = 10**10 10**10 ans ans = min(ans, sum((i-x)**2 for x in X)) min(ans, sum((i-x)**2 for x in X)) ans X = sorted(list(map(int,input().split()))) sorted(list(map(int,input().split()))) X n = int(input()) int(input()) n
n = int(input())
X = sorted(list(map(int,input().split())))
ans = 10**10

for i in range(X[0],X[-1]+1):
    ans = min(ans, sum((i-x)**2 for x in X))

print(ans)