import numpy as np

import math



n = int(eval(input()))

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



p1_sum = []

p2_sum = []



p1 = math.floor((1/n) * sum(x))

p2 = math.ceil((1/n) * sum(x))



for i in x:

    p1_sum.append((p1 - i)** 2)

    p2_sum.append((p2 - i)** 2)



print((min(sum(p1_sum),sum(p2_sum))))
n = int(eval(input()))

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

p = round((1/n) * sum(x))



ans = 0

for i in x:

    ans += (p -i) ** 2



print(ans)
import numpy as np
import math

n = int(eval(input()))
x = list(map(int, input().split()))
p1_sum = []
p2_sum = []
p1 = math.floor((1 / n) * sum(x))
p2 = math.ceil((1 / n) * sum(x))
for i in x:
    p1_sum.append((p1 - i) ** 2)
    p2_sum.append((p2 - i) ** 2)
print((min(sum(p1_sum), sum(p2_sum))))

n = int(eval(input()))
x = list(map(int, input().split()))
p = round((1 / n) * sum(x))
ans = 0
for i in x:
    ans += (p - i) ** 2
print(ans)

-import numpy as np -import math - -p1_sum = [] -p2_sum = [] -p1 = math.floor((1 / n) * sum(x)) -p2 = math.ceil((1 / n) * sum(x)) +p = round((1 / n) * sum(x)) +ans = 0 -    p1_sum.append((p1 - i) ** 2) -    p2_sum.append((p2 - i) ** 2) -print((min(sum(p1_sum), sum(p2_sum)))) +    ans += (p - i) ** 2 +print(ans)