import math



n = int(eval(input()))

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

p = sum(x) / len(x)



a1 = sum([(a - math.floor(p)) * (a - math.floor(p)) for a in x])

a2 = sum([(a - math.ceil(p)) * (a - math.ceil(p)) for a in x])

print((min(a1, a2)))
import math

n = int(eval(input()))

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



p = sum(xs) / len(xs)

x1 = sum([(x - math.floor(p)) ** 2 for x in xs])

x2 = sum([(x - math.ceil(p)) ** 2  for x in xs])

print((min(x1, x2)))
import math

n = int(eval(input()))
x = list(map(int, input().split()))
p = sum(x) / len(x)
a1 = sum([(a - math.floor(p)) * (a - math.floor(p)) for a in x])
a2 = sum([(a - math.ceil(p)) * (a - math.ceil(p)) for a in x])
print((min(a1, a2)))

import math

n = int(eval(input()))
xs = list(map(int, input().split()))
p = sum(xs) / len(xs)
x1 = sum([(x - math.floor(p)) ** 2 for x in xs])
x2 = sum([(x - math.ceil(p)) ** 2 for x in xs])
print((min(x1, x2)))

-x = list(map(int, input().split())) -p = sum(x) / len(x) -a1 = sum([(a - math.floor(p)) * (a - math.floor(p)) for a in x]) -a2 = sum([(a - math.ceil(p)) * (a - math.ceil(p)) for a in x]) -print((min(a1, a2))) +xs = list(map(int, input().split())) +p = sum(xs) / len(xs) +x1 = sum([(x - math.floor(p)) ** 2 for x in xs]) +x2 = sum([(x - math.ceil(p)) ** 2 for x in xs]) +print((min(x1, x2)))