# C - Rally

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

c = []
x_ave = int(sum(x)/n)
s = 0
for i in range(n):
    s += (x[i]-x_ave)**2
c.append(s)
s = 0
for i in range(n):
    s += (x[i]-x_ave-1)**2
c.append(s)


print(min(c)) n = int(input()) n int(input()) int input() input x = list(map(int,input().split())) x list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split c = [] c [] x_ave = int(sum(x)/n) x_ave int(sum(x)/n) int sum(x)/n sum(x) sum x n s = 0 s 0 for i in range(n):
    s += (x[i]-x_ave)**2 i range(n) range n s += (x[i]-x_ave)**2 s (x[i]-x_ave)**2 x[i]-x_ave x[i] x i x_ave 2 c.append(s) c.append c append s s = 0 s 0 for i in range(n):
    s += (x[i]-x_ave-1)**2 i range(n) range n s += (x[i]-x_ave-1)**2 s (x[i]-x_ave-1)**2 x[i]-x_ave-1 x[i]-x_ave x[i] x i x_ave 1 2 c.append(s) c.append c append s print(min(c)) print min(c) min c s += (x[i]-x_ave-1)**2 (x[i]-x_ave-1)**2 s x = list(map(int,input().split())) list(map(int,input().split())) x x_ave = int(sum(x)/n) int(sum(x)/n) x_ave s = 0 0 s s = 0 0 s s += (x[i]-x_ave)**2 (x[i]-x_ave)**2 s n = int(input()) int(input()) n c = [] [] c
# C - Rally

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

c = []
x_ave = int(sum(x)/n)
s = 0
for i in range(n):
    s += (x[i]-x_ave)**2
c.append(s)
s = 0
for i in range(n):
    s += (x[i]-x_ave-1)**2
c.append(s)


print(min(c))
