peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
X = [int(i) for i in input().split()]
r = min(X)
l = max(X)
ans = float("INF")
num = 0
for i in range(r, l+1):
  for x in X:
    num += (x-i)**2
  ans = min(ans, num)
  num = 0
print(ans)
N = int(input())
X = list(map(int,input().split()))

ans = 0
mx = 10**100
for i in range(1,101):
    mm = 0
    for j in range(N):
        mm += (i-X[j])**2

    mx = min(mx,mm)
print(mx)
n = int(input())
x = list(map(int,input().split()))

m = min(x)
M = max(x)
ans = 10**9
for i in range(m,M+1):
  cost = 0
  for j in range(n):
    cost += (x[j]-i)**2
    
  ans = min(ans,cost)
print(ans)
N = int(input())
li = list(map(int,input().split()))	
Sum = 0
for i in range(len(li)):
    Sum += li[i]
ave = int((Sum / len(li)) + 0.5)

S = 0
for i in range(len(li)):
    S += (li[i] - ave) ** 2
print(S)
n = int(input())
x = [int(i) for i in input().split()]

print(  min( sum( (xx-p)**2 for xx in x ) for p in range(max(x)+2) ) )
import numpy as np

N = int(input())
X = [int(i) for i in input().split()]

xmin = min(X)
xmax = max(X)

vmin = 1e6
for i in range(xmin, xmax+1):
    v = sum((np.array(X) - i) ** 2)
    if v < vmin:
        vmin = v

print(vmin)
n = input()
s = list(map(int,input().split()))
m = 10000000
for p in range(0,101):
  t = 0
  for x in s:
    t+=(x-p)**2
  m = min(t,m)
print(m)
#!/usr/bin/env python3
# %%
stdin = open(0)
import numpy as np
 
# %%
data = np.fromstring(stdin.read(), np.int64, sep=' ')
 
# %%
X = data[1:]
costs = []
for p in range(101):
    costs.append(np.sum((X-p)**2))
 
# %%
answer = min(costs)
print(answer)
#!/usr/bin/env python3
import numpy as np
import math

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

p1 = math.floor(np.mean(x))
p2 = math.ceil(np.mean(x))
ans1 = 0 
ans2 = 0 
for i in x:
    ans1 += (i-p1)**2
    ans2 += (i-p2)**2

print(min(ans1, ans2))
def resolve():
    n = int(input())
    x = list(map(int, input().split()))
    x.sort()
    xx = [0 for i in range(n)]
    for i,j in enumerate(x):
        xx[i] = j**2
    minp = 100
    for i in range(200):
        k = i*(n*i - 2*sum(x))
        if k < minp:
            minp = k
    print(sum(xx)+ minp)
if __name__ == "__main__":
    resolve()
N=int(input())
x=list(map(int,input().split()))

p=sum(x)/N

import math

z1=0
z2=0
for i in range(N):
  z1+=(x[i]-math.floor(p))**2
  z2+=(x[i]-math.ceil(p))**2
  
print(min([z1,z2]))
N = int(input())
X = input().split()
X = list(map(int, X))

s = sum(X)
mean = round(s / N)

P = []
for i in range(N):
    P.append((X[i]-mean)**2)

print(sum(P))
n = input()
l = map(int,raw_input().split())
mxs = 10**9


for i in range(max(l)):
    sm = 0
    for j in l:
        sm += (j-i)**2
    if sm<mxs:
        mxs = sm
print mxs
n = int(input())
x = [int(i) for i in input().split()]
x.sort()

ans = 10000

for p in range(x[-1]):
  sum =0
  for i in range(n):
    sum += (x[i]-p)**2
    
  ans = min(ans,sum)
  
  
print(ans)
N=int(input())
X=list(map(int,input().split()))
s=0
sum=0
for i in X:
    sum+=i

sum=round(sum/len(X),0)
print(sum)
for i in X:
    tmp=(i-sum)**2
    s=s+tmp
print(s)
N = int(input())
X = list(map(int, input().split()))

cnt = 0
mini = float('inf')

P = max(X)

for i in range(1, P):
    for j in range(len(X)):
        cnt += (X[j] - i)**2
    if cnt < mini:
        mini = cnt
    cnt = 0

print(mini)
import numpy as np
import math

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

avg = np.mean(lst)
avg= math.ceil(avg)

ans = 0
for _ in lst:
    ans += (_ - avg) ** 2
    
print(ans)
N = int(input())
X = input().split()
X = [int(s) for s in X]

X = sorted(X)
range_X = X[-1] - X [0]

E_min = 10000000000000
for p in range(range_X):
    E = 0
    for x in X:
        E += (x-p)**2
    if E < E_min:
        E_min = E
print(E_min)
import numpy as np
N=int(input())
X=np.array(list(map(int,input().split())))
ans=sum(X**2)
for i in range(min(X),max(X)):
    Z=sum(X**2)-sum(2*X*i)+N*i**2
    ans=min(Z,ans)
print(ans)
import math

N = int(input())
X = list(map(int, input().split()))
sum = 0
all = True
max = 0
for a in X:
    sum = sum + a
    if max < a:
        max = a -1
    for c in X:
        if(a != c):
            all = False
ans = 0
for b in X:
    ans = ans + (b-math.ceil(max))**2
if all == True:
    ans = 0
    print(ans)
else:
    print(ans)
n = int(input())
x = list(map(int,input().split()))
S = sum(x)
Ave = sum(x) // n
m = 10**6
score = 0
count = 0

for p in range(Ave-100,Ave+101): 
    for i in range(n):
        score += (x[i]-p)**2
    if score < m:
        m = score
        score = 0
print(m,p)
N = int(input())
X = list(map(int, input().split()))
sum_min = 10**5

for i in range(min(X), max(X)+1):
    s = 0
    for j in range(N):
        s += (X[j] - i)**2
    
    if s < sum_min:
        sum_min = s

print(sum_min)
N = int(input())
Xl = list(map(int, input().split()))
Xl.sort()
minx = Xl[0]
maxx = Xl[-1]
minsum = 1000000
for i in range(minx, maxx):
    sumd = 0
    for x in Xl:
        sumd += (x - i)**2
    if sumd < minsum:
        minsum = sumd
print(minsum)
n = int(input())
x = list(map(int, input().split()))
s = sum(x)
p = (s+n-1)//n
r = 0
for y in x:
    r += (y - p)**2
print(r)
n = int(input())
x = list(map(int, input().split()))
hel = []
cnt = 0
for i in range(max(x)):
    for j in range(n):
        cnt += abs(x[j] - i) ** 2
    hel.append(cnt)
    cnt = 0
print(min(hel))
n = int(input())
x = list(map(int, input().split()))

m = 100 * 100 * n
sumlist = []

for i in range(max(x)):
    s = 0
    for j in range(n):
        s += (x[j] - i) ** 2

    sumlist.append(s)

print(min(sumlist))
n = int(input())
list = []
list1 = []
list2 = []
list3 = []
c = 0
a = input().split()
for i in range(0, len(a)):
    list1.append(int(a[i]))
for j in range(1, 100):
    for item in list1:
        c = c+ (item-j)**2
    list2.append(c)
l = len(list2)
for z in range(0, l-1):
    list3.append(list2[z+1]-list2[z])
list3.sort()
print(list3[0])
n = int(input().strip())
# s = input().strip()
# A, B, C = map(int, input().strip().split())
L = list(map(int, input().strip().split()))
# L = [int(input().strip()) for _ in range(n)]
# L = [list(map(int, input().split())) for _ in range(n)]
ans=10**6+1
for p in range(L[-1]+1):
    tmp=0
    for x in L:
        tmp+=(x-p)**2
    ans=min(ans,tmp)
print(ans)
n = int(input())
l = list(map(int,input().split()))
if len(set(l)) == len(l):
    mean = (sum(l))//len(l)
else:
    mean = (sum(set(l)))//(n-1)
print(sum(pow(i - mean, 2) for i in l))
n = int(input())
l = list(map(int, input().split()))
sl = [0]

ma, mi = max(l), min(l)

for x in range(mi, ma):
  s = 0
  for i in l:
    s += (i - x)**2 
  sl.append(s)

print(min(sl))
n=int(input())
xlis = list(map(int,input().split()))
def tai(p,x):
  return pow(x-p,2)
ans=999999999999
for i in range(min(xlis),max(xlis)-min(xlis)+1):
  sum=0
  for j in xlis:
    sum+=tai(i,j)
  if ans>sum:
    ans=sum
    
print(ans)
n = int(input())
address = list(map(int, input().split()))
sort_address = sorted(address)
sum = 0
sum_min = 100000

for i in range(sort_address[0], sort_address[-1] + 1):
    for j in sort_address:
        sum += (i - j)**2
    if sum < sum_min:
        sum_min = sum
    sum = 0
print(sum_min)
import numpy as np

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

m = int(np.median(x))
k = int(np.std(x))
ans = max(x) ** 2 * n

# pos = m + k
# print(pos)
# cost = 0

low = max(1, m - k)
high = min(m + k, np.max(x))

for i in range(low, high, 1):
  cost = 0
  for j in range (n):
    cost += (x[j] - i) ** 2
  # print(cost)
  if cost < ans:
    ans = cost

print(ans)
N = int(input())
X = list(map(int, input().split()))

mini = min(X)
maxi = max(X)
consume = 10000

for i in range(mini, maxi):
    pos = i
    total = sum([(pos - j) ** 2 for j in X])
    consume = min(total, consume)

print(consume)
n=int(input())
l=list(map(int, input().split()))
x=sum(l)//n +1
ct=0
for i in l:
  ct+=(x-i)**2
print(ct)
N = int(input())
X = list(map(int, input().split()))
min_X = min(X)
max_X = max(X)
ans = float("inf")
for p in range(min_X, max_X):
    tmp = 0
    for x in X:
        tmp += (x - p) ** 2
    ans = min(ans, tmp)
print(ans)
N = int(input())
X = list(map(int, input().split()))
X.sort()
a = -1
for i in range(X[0], X[-1]):
    b = 0
    for y in X:
        b += (y - i)**2
    if a == -1 or b < a:
        a = b
    elif a < b:
        break
print(a)
n = int(input())
x = [int(a) for a in input().split()]
ans = 0
for i in range(101):
    res = 0
    for j in x:
        res += (j-i)**2
    if ans==0:
        ans = res
    elif ans > res:
        ans = res
print(ans)
N = int(input())
X = list(map(int, input().split()))
M = sum(X)//N
ans = 0
for i in X:
    ans+=(i-M)**2
print(ans)
P=int(input())
X=list(map(int,input().split()))
l=[]
for j in range(min(X)-1,max(X)):
    ans = [(i-j)**2 for i in X ]
    l.append(sum(ans))
print(min(l))
import math

N = int(input())
X = list(map(int, input().split()))
sum = 0
all = True
max = 0
for a in X:
    sum = sum + a
    if max <= a:
        max = a
    for c in X:
        if(a != c):
            all = False
ans = 0
for b in X:
    ans = ans + (b-math.ceil(max))**2
if all == True:
    ans = 0
    print(ans)
else:
    print(ans)
N=int(input())
X=list(map(int,input().split()))
ans = 100000000
res = 0
for j in range(1,100):
  for i in range(N):
    res += (X[i]-j)**2
  ans=min(ans,res)
print(ans)
n=int(input())
x=list(map(int,input().split()))
result=0
for p in range(1,max(x)):
  s=0
  for i in range(0,n):
    s+=(x[i]-p)**2
  if p==1:
    result=s
  else:
    if s<result:
      result=s
print(result)
N=int(input())
X=list(map(int,input().split()))

max=max(X)
ans = 100*5*N
for i in range(max+1):
    tmp=0
    for x in X:
        tmp+=(x-i)**2
    ans=min(ans,tmp)
print(ans)
n = int(input())
x = list(map(int,input().split()))

phy = []
tmp = 0
max = 0
count = 0

for i in range(101):
    phy.append(i*i)

for j in range(1,x[n-1]):
    for k in range(n):
        tmp += phy[abs((j-x[k]))]
    if(max > tmp or count == 0):
        max = tmp
    count += 1
    tmp = 0

print(max)
N = int(input())
X = list(map(int,input().split()))
X.sort()
min = 100*100
for t in range(1, 101):
    sum = 0
    for x in X:
        sum += (x - t)**2
    if sum < min: min = sum
print(min)
n = int(input())
x = list(map(int, input().split()))
ans = float('inf')
for s in range(min(x),max(x)):
    ans_pre = 0
    for i in x:
        ans_pre += (i-s)**2
    ans = min(ans,ans_pre)

print(ans)
n = int(input())
X = list(map(int, input().split()))
dist = 1000000000
d = 0
for i in range(X[0], X[n - 1]):
	for x in X:
		d += (x - i) * (x - i)
	if d < dist:
		dist = d
	d = 0
print(dist)
N=int(input())
a=list(map(int,input().split()))
s=[]
for i in range(101):
  for j in range(0,len(a)):
    m=0
    m+=(a[j]-i)**2
    s.append(m)
print(min(s))
N = int(input())
X = sorted([int(x) for x in input().split()])
min_cost = 10**12
for p in range(X[0]+1, X[-1]):
    cost_sum = 0
    for x in X:
        cost_sum += (x-p)**2
    min_cost = min(min_cost, cost_sum)

print(min_cost)
n = int(input())
x = [int(x) for x in input().split()]
sum = 0
list = [] * n
for i in range(n):
    sum = 0
    for j in range(n):
        sum = sum + (x[j] - (i+1))**2
    list.append(sum)
print(min(list))
#!/usr/bin/env python3 ## -*- python -*-
import sys

n = int(input())
x = []
for c in input().split():
  x.append(int(c))
print(x)
a = sys.maxsize
for i in range(min(x), max(x)):
    c = 0
    for j in x:
        c = c + (j-i) * (j-i)
    a = min([a, c])
print(a)
N = int(input())
Xn = [int(x) for x in input().split()]
L = Xn[0]
R = Xn[0]
for i in range(N):
    L = min(L, Xn[i])
    R = max(R, Xn[i])

ans = float('inf')
for i in range(L,R):
    pos = 0
    for j in Xn:
        pos += (j-i)*(j-i)
    ans = min(ans, pos)
print(ans)
N=int(input())
X=list(map(int,input().split()))

print(sum([(xi-(sum(X)+N-1)//N)**2 for xi in X]))
n=int(input())
x=[int(i) for i in input().split(" ")]
x=sorted(x)
mind=-1
for i in range(x[0],x[len(x)-1]):
    sum=0
    for j in x:
        sum+=(j-i)**2
    if mind>sum or mind==-1:
        mind=sum

print(mind)
lenght = int(input())
people = [int(i) for i in input().split()]
resultList = []
for i in range(min(people), max(people)):
  mylist = []
  for j in people:
    mylist.append((j - i) ** 2)
  resultList.append(sum(mylist))
if(len(resultList) == 0):
  print(people[0])
else:
  print(min(resultList))
N = int(input())
X_list = [int(i) for i in input().split()]

low = min(X_list)
high = max(X_list)

minimum = high
for p in range(low,high) :
    tmp = 0
    for x in X_list :
        tmp += pow(x-p,2)
    
    if (tmp < minimum) :
        minimum = tmp

print(minimum)
N = int(input())
X = list(map(int, input().split()))

hp_sums = []

for i in range(max(X)):
    P = i+1
    distance_list = list(map(lambda x: (x-P)**2, X))
    print(distance_list)
    hp_sum = sum(distance_list)
    hp_sums.append(hp_sum)

print(min(hp_sums))
N = int(input())
X = [int(n) for n in range(N)]

min_ans = +float('inf')

for i in range(N):
    ans = 0
    for x in X:
        ans += (x - i)**2
    min_ans = min([min_ans, ans])

print(min_ans)
n = int(input())
x = [int(i) for i in input().split()]

ans = 1000000
for i in range(max(x)):
  l = 0
  for j in range(n):
    l += (x[j]-i)**2
  if ans > l:
    ans = l
    
print(ans)
import math
a=int(input())
s=list(map(int,input().split()))
p=sum(s)/a
psum=0
for i in s:
    psum+=(i-p)**2
print(math.ceil(psum))
import math
N = int(input())
x = list(map(int, input().split()))
 
t = 0
min = 0

for i in range(0,N-1):
     t += x[i]/N

s = math.floor(t)
print(s)
for i in range(0,N-1):
    min += (x[i] - s) **2

print(min)
n = int(input())
x_list = list(map(int, input().split(" ")))


min = min(x_list)
max = max(x_list)

ans = 100*100

for p in range(1, 100+1):
    tmp = 0
    for x in x_list:
        tmp += (x - p) ** 2
    if ans > tmp:
        ans = tmp

print(ans)
n = int(input())
x = list(map(int, input().split()))
x.sort()
mid = x[len(x)//2]
strt = mid
res = 10**7
if strt>n//2:
  strt = n//2
  for i in range(strt,x[-1]):
    tmp = 0
    for j in x:
      tmp += (j-i)**2
    res = min(tmp,res)
else:
  strt = 0
  for i in range(strt,mid):
    tmp = 0
    for j in x:
      tmp += (j-i)**2
    res = min(tmp,res)
print(res)
N = int(input())
X = list(map(int, input().split()))
ans = 0
for i in range(1, N+1):
  k = []
  for a in X:
    k.append((a-i)**2)
  if i==1:
    ans = sum(k)
  if ans>sum(k):
    ans = sum(k)
print(ans)
n=int(input())
x=list(map(int,input().split()))

a=sum(x)//n+1

m=999999999999
for i in range(x[0],x[n-1]):
    a=i
    s=0
    for i in range(n):
        s+=(x[i]-a)**2
    m=min(m,s)

print(m)
n = int(input())
x = [int(i) for i in input().split()]
x.sort()

ans = 10000
for p in range(1,x[-1]*2):
  sum =0
  for i in range(n):
    sum += (x[i]-p)**2
    
  ans = min(ans,sum)
  
print(ans)
n = int(input())
r = list(map(int, input().split()))
o = (max(r) + min(r)) // 2
old = None
for x in range(o//2, max(r)):
  t = sum([(i - x) ** 2 for i in r])
  if not old:
      old = t
      continue
  if t < old:
    old = t
print(old)
import sys
import math
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))

n = ini()
a = inl()
x = sum(a) // n
ans = 0
for i in a:
    ans += (i - x) * (i - x)
print(ans)
N=int(input())
X=list(map(int,input().split()))
ave=sum(X)//N
a=[(X[i]-ave)**2 for i in range(N)]
b=[(X[i]-ave+1)**2 for i in range(N)]
print(min(sum(a),sum(b)))
N = int(input())
X_s = tuple(map(int,input().split()))
MIN = 10**5
for i in range(1,101):
  SUM = sum(tuple(map(lambda x:(x-i)**2, X_s)))
  if MIN > SUM:
    MIN = SUM
print(MIN)
N = int(input())
X = list(map(int, input().split()))

ans = 0

for i in X:
  ans += (N-i)**2
 

print(ans)
def calculate_hp(n,x):
  total_hp = 0
  xlist = [int(s) for s in x]
  for i in xlist:
    hp = (i-n) ** 2
    total_hp+=hp    
  return total_hp
def main():
  n = int(input())
  x = input().split()
  total_hp=calculate_hp(n, x)
  print(total_hp)

main()
def resolve():
    N = int(input())
    x_list = list(map(int, input().split()))

    x_min = min(x_list)
    x_max = max(x_list)
    hp_min = 10**18

    for i in range(x_min, x_max):
        tmp_hp = 0
        for j in x_list:
            tmp_hp += (j - i)**2
        if (hp_min is None) or (tmp_hp < hp_min):
            hp_min = tmp_hp

    print(hp_min)

if __name__ == "__main__":
    resolve()
n = int(input())

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

ans = 0

x_sum = sum(x_list) //  n + 1

for x in x_list:
    ans += (x-x_sum)**2
    continue

print(ans)
N=int(input())
list = list(map(int, input().split()))

l=len(list)
m=0
i=0
j=1
r=0

while(i<l):
  if(m < abs(list[i]-j)):
    m = j
  i+=1
  j+=1

k=0

while(k<l):
  r+=abs(list[k]-m)*abs(list[k]-m)
  k+=1

print(r)
N = int(input())
X = [int(x) for x in input().split()]
allpoint = []
for j in range(1, X[-1]+1):
    total = 0
    for i in X:
        total += (i - j)**2
    allpoint.append(total)
print(min(allpoint))
n=int(input())
x=list(map(int,input().split()))
p=sum(x)//n+1
answer=0
for i in range(n):
    answer+=(x[i]-p)**2
print(answer)
# C
N = int(input())
A = list(map(int,input().split()))
mi = min(A)
ma = max(A)
ans = 10 ** 12
for i in range(mi,ma):
    su = 0
    for j in A:
        su += (i-j)**2
    ans = min(ans,su)
print(ans)
import math

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

mean = math.ceil(sum(x) / n)

ans1 = 0
for i in range(n):
	ans1 += (x[i]-mean) ** 2

if sum(x) % n != 0:
	ans2 = 0
	for i in range(n):
		ans2 += (x[i]-mean) ** 2

	print(min(ans1,ans2))
else:
	print(ans1)
N = int(input())
X = list(map(int, input().split()))
import math
av = math.ceil(sum(X)/N)
total = 0

for i in X:
    total += ((i-av)**2)

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

x_min = x[0]
x_max = x[n-1]
min_sum = 10000000
for p in range(x_min, x_max):

    sum = 0
    for e in x:
        len = (e - p)**2
        sum += len
    # print("p", p, "sum", sum, "min_sum", min_sum)
    if sum <= min_sum:
        min_sum = sum
print(min_sum)
n = int(input())
xi = list(map(int, input().split()))

cost = []
for p in range(max(xi)):
    tmp = 0
    for i in xi:
        tmp += pow((p - i), 2)
    cost.append(tmp)

print(min(cost))
N = int(input())

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

max_x = max(x_list)
min_x = min(x_list)

each_value_list = []
min_value = 10e1000
for i in range(min_x, max_x + 1):
    print(i)
    tmp_sum = 0
    for x in x_list:
        tmp_sum += (x - i)**2
    if min_value > tmp_sum:
        min_value = tmp_sum

print(min_value)
def main():
    N = int(input())
    x_line = list(map(int, input().split(' ')))
    max_x = max(x_line)
    min_x = min(x_line)
    result = 10000
    for i in range(min_x, max_x + 1):
        hash_result = 0
        for x in x_line:
            hash_result += (x - i) ** 2
        if hash_result < result:
            result = hash_result
    print(result)


if __name__ == '__main__':
    main()
import os

def main():
    count = int(input())
    int_list = list(map(int, input().split()))
    int_min,int_max = min(int_list),max(int_list)
    score = 0

    int_avg = int(sum(int_list) / len(int_list)) + 1
    print(int_avg)
    for i in int_list:
        score += (i - int_avg)**2
    print(score)

if __name__ == "__main__":
    main()
N = int(input())
List = list(map(int, input().split()))
s = 0
t = 0

for i in range(100):
  for j in range(N):
    t += (List[j]-i-1)**2

  if s>t:
    s = t

print(t)
n = int(input())
x = list(map(int, input().split()))
s = sum(x)
p = (s+n-1)/n
r = 0
for y in x:
    r += (y - p)**2
print(r)
N=int(input())
X=list(map(int,input().split()))
p=sum(X)//len(X)
ans=0
for i in range(len(X)):
    ans+=(X[i]-p)**2
print(ans)
import sys 
read = sys.stdin.buffer.read
N,*X = map(int,read().split())
s = sum(X)
res = [(x-s)**2 for x in X]
print(sum(res))
n = int(input())
x = list(map(int, input().split()))
mid = int(sum(x)/n)
ans = 1000000000
total = 0
for j in range(x[0], x[n-1]):
    for i in range(n):
        total += (x[i] - j)**2
    if total < ans:
        ans = total
        total = 0
print(ans)
import numpy as np
import math

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

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

h = -(1/n)*(sum(x)**2)
m = np.array(x)
d = sum(m ** 2)

print(math.ceil(h + d))
import math
N = int(input())
X = list(map(int, input().split()))
P = int(math.ceil(sum(X) / N))
print(sum((x - P)**2 for x in X))
import math
N = int(input())
A = list(map(int, input().split()))
X = sum(A)//N
ans = 0
for i in A:
  ans += (i-X)**2
print(math.ceil(ans))
N = int(input())
X = list(map(int,input().split()))
ans = max(X) **2
for i in range(1,100):
    sum = 0
    for j in range(N):
        sum += (X[j]-i)**2
    ans = min(ans,sum)
print(ans)
n=int(input())
x=list(map(int,input().split()))
ans=10**12
cou=0

for i in range(min(x),max(x)):
  for j in range(n):
    cou+=(x[j]-i)**2
  if cou<ans:
    ans=cou
  cou=0  
print(ans)
import numpy as np

def Rally(n, array):
    min_ = max(np.array(array)*100)
    for i in range(0,max(np.array(array))):
        if min_ > sum((np.array(array)-i)**2):
            min_ = sum((np.array(array)-i)**2)
    return min_

n = int(input())
array = list(map(int,input().split()))
print(Rally(n, array))
import numpy as np
 
N = input()
X = list(map(int, input().split()))
ans=9999999
for P in range(max(X)):
  sum = np.sum(list(map(lambda x: (x-P)**2, X)))
  ans = min(ans, sum)
    
print(ans)
import statistics
import math
import numpy as np

N=int(input())
X=list(map(int,input().split()))
X.sort()
#print(X)
med=int(statistics.median(X))

min=10**10
sum=0
while True:
    sum=0
    for i in range(N):
        sum+=(X[i]-med)**2
    if sum<min:
        min=sum
        prev=sum
        med+=1
    else:
        break

print(prev)
N = int(input())
X = list(map(int, input().split()))

Max = max(X)
p_min = 10000
for i in range(1, Max+1):
    p = 0
    for j in range(len(X)):
        p += (X[j] - i)**2
    if  p < p_min:
        p_min = p
    else:
        p_min = p_min
print(p_min)
s = map(int,input().split())
m = 10000000
for p in s:
  t = 0
  for x in s:
    t+=(x-p)**2
  m = min(t,m)
print(m)
import math
n = int(input())
X = list(map(int, input().split()))

p=(math.ceil(sum(X)/n))
cnt=0
for x in X:
  cnt += (x-p)**2
  
print(cnt)
import numpy as np

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

m = int(np.median(x))
k = int(np.std(x))
ans = max(x) ** 2 * n

# pos = m + k
# print(pos)
# cost = 0

for i in range(m-k, m+k, 1):
  cost = 0
  for j in range (n):
    cost += (x[j] - i) ** 2
  # print(cost)
  if cost < ans:
    ans = cost

print(ans)
N = int(input())
Xs = list(map(int,input().split()))
ans = 0
ansCandidate = 0
for j in range(min(Xs),max(Xs)):
    ansCandidate = 0
    for i in range(N):
        ansCandidate += (Xs[i] - j)**2
    print(ansCandidate)
    if j == min(Xs):
        ans = ansCandidate
    ans = min(ans,ansCandidate)
print(ans)
N=int(input())
X=list(map(int,input().split()))

sum=0
A=[]

for i in range(int(X[N-1]+5)):
    for j in range(N):
        sum+=(X[j]-i)**2
    A.append(sum)
    sum=0

print(min(A))
import numpy as np
import math

N = list(map(int, input().split()))
X = list(map(int, input().split()))


P = N[0]//2

suma = 0
for a in range(N[0]):
    suma = suma + (X[a] + P)**2

Q = (N[0]//2)+1
sumb = 0
for b in range(N[0]):
    sumb = sumb + (X[b] + Q)**2
if suma < sumb:
    print(suma)
else:
    print(sumb)
n = int(input())
x = list(map(int, input().split()))
hp_min = 10000 * n
for i in range(min(x), max(x)):
    hp = sum([(x[j] - i) ** 2 for j in range(len(x))])
    if hp < hp_min:
        hp_min = hp
print(hp_min)
n=int(input())
x=list(map(int,input().split()))
m=1000000
for i in range(n):
    su=0
    for j in range(n):
        su+=(x[j]-i-1)**2
    if m>su:
        m=su
print(su)
N = int(input())
X = list(map(int, input().split()))

ave = -1*(-1*sum(X)//len(X))
dist = [(i-ave)**2 for i in X]

print(sum(dist))
N = int(input())
X = [float(x) for x in input().split()]

P = round(sum(X)/N)
print(sum([(x-P)**2 for x in X]))
N = int(input())
X = list(map(int, input().split()))

ans = 10000
P = 100
while P > 0:
    a = 0
    for x in X:
        a += (x - P) ** 2
    ans = min(ans, a)
    P -= 1
print(ans)