n = int(eval(input()))

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

S = sum(x)

Ave = sum(x) // n

m = 10**6

score = 0



for p in range(Ave,Ave+1001): 

    for i in range(n):

        score += (x[i]-p)**2

    if score < m:

        m = score

        score = 0

print(m)
#恐らく平均値に最も近い整数が答えになるかと思われる

n = int(eval(input()))

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

Ave = sum(x) / n

point = 0





for i in range(n):

    point += (x[i]-round(Ave))**2 

print(point)
n = int(eval(input()))
x = list(map(int, input().split()))
S = sum(x)
Ave = sum(x) // n
m = 10**6
score = 0
for p in range(Ave, Ave + 1001):
    for i in range(n):
        score += (x[i] - p) ** 2
    if score < m:
        m = score
        score = 0
print(m)

# 恐らく平均値に最も近い整数が答えになるかと思われる
n = int(eval(input()))
x = list(map(int, input().split()))
Ave = sum(x) / n
point = 0
for i in range(n):
    point += (x[i] - round(Ave)) ** 2
print(point)

+# 恐らく平均値に最も近い整数が答えになるかと思われる -S = sum(x) -Ave = sum(x) // n -m = 10**6 -score = 0 -for p in range(Ave, Ave + 1001): -    for i in range(n): -        score += (x[i] - p) ** 2 -    if score < m: -        m = score -        score = 0 -print(m) +Ave = sum(x) / n +point = 0 +for i in range(n): +    point += (x[i] - round(Ave)) ** 2 +print(point)