def dist(x, p):
    return (x - p)**2


n = int(input())
x = [int(i) for i in input().split()]
index = len(x) // 2
new_x = sorted(x)
p1 = - (- sum(x) // len(x))
p2 = sum(x) // len(x)
ans = [0, 0]
for i in new_x:
    ans[0] += dist(i, p1)
    ans[1] += dist(i, p2)
print(min(ans)) def dist(x, p):
    return (x - p)**2 dist return (x - p)**2 (x - p)**2 x - p x p 2 x x p p n = int(input()) n int(input()) int input() input int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i x = [int(i) for i in input().split()] x [int(i) for i in input().split()] index = len(x) // 2 index len(x) // 2 len(x) len x 2 new_x = sorted(x) new_x sorted(x) sorted x p1 = - (- sum(x) // len(x)) p1 - (- sum(x) // len(x)) - sum(x) // len(x) - sum(x) sum(x) sum x len(x) len x p2 = sum(x) // len(x) p2 sum(x) // len(x) sum(x) sum x len(x) len x ans = [0, 0] ans [0, 0] 0 0 for i in new_x:
    ans[0] += dist(i, p1)
    ans[1] += dist(i, p2) i new_x ans[0] += dist(i, p1) ans[0] ans 0 dist(i, p1) dist i p1 ans[1] += dist(i, p2) ans[1] ans 1 dist(i, p2) dist i p2 print(min(ans)) print min(ans) min ans x = [int(i) for i in input().split()] [int(i) for i in input().split()] x def dist(x, p):
    return (x - p)**2 def dist(x, p):
    return (x - p)**2 dist p2 = sum(x) // len(x) sum(x) // len(x) p2 new_x = sorted(x) sorted(x) new_x ans = [0, 0] [0, 0] ans p1 = - (- sum(x) // len(x)) - (- sum(x) // len(x)) p1 n = int(input()) int(input()) n index = len(x) // 2 len(x) // 2 index
def dist(x, p):
    return (x - p)**2


n = int(input())
x = [int(i) for i in input().split()]
index = len(x) // 2
new_x = sorted(x)
p1 = - (- sum(x) // len(x))
p2 = sum(x) // len(x)
ans = [0, 0]
for i in new_x:
    ans[0] += dist(i, p1)
    ans[1] += dist(i, p2)
print(min(ans))