peterverebics/CodeNet_Python_118 huggingface dataset:
N, = list(map(int, input().split()))
X = list(map(int, input().split()))

best = float('inf')
for p in range(1, 101):
    best = min(best, sum((x - p) ** 2 for x in X))
print(best)
input()
xs = list(map(int, input().split()))

ans = min(map(lambda p: sum(map(lambda x: (x - p) ** 2, xs)), range(1, 101)))
print(ans)
if __name__ == '__main__':
	n = int(input())
	A = list(map(int,input().split()))
	ma = max(A) + 1
	ans = 1000000
	for x in range(1,ma):
		tmp = 0
		for y in A:
			tmp2 = (y-x)*(y-x)
			tmp += tmp2
		ans = min(ans,tmp)
	
	print(ans)
n = int(input())
X = sorted(list(map(int,input().split())))
ans = 10**10

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

print(ans)
N=int(input())
X=list(map(int,input().split()))
a=round(sum(X)/N)
Y=[]
for i in X:
    Y.append((i-a)**2)
print(sum(Y))
import math
n = int(input())
x = list(map(int,input().split()))
s = min(x)
e = max(x)
ans = 10**18
for i in range(s,e+1):
  f = 0
  for j in range(n):
    f += (x[j]-i)**2
  ans = min(ans,f)
print(ans)
import numpy as np

N = int(input())
X = [int(x) for x in input().split()]
X = np.array(X)

ans = 1e6
for x in range(1, 100) :
    s = (X-x)**2
    ans = min(ans, s.sum())
print(ans)
import numpy as np
N = int(input())
x_list = list(map(int,input().split()))

pos = round(np.mean(x_list))
ans = sum([(x-pos)**2 for x in x_list])
print(int(ans))
n = int(input())
x = [int(i) for i in input().split()]
mn = 10**9
for p in range(101):
    sum_mn = 0
    for i in range(n):
        sum_mn += (p-x[i])**2
    if mn > sum_mn:
        mn = sum_mn
print(mn)
n = int(input())
x = list(map(int,input().split()))


maxi = max(x)
mini = min(x)

tairyoku_1=1000000000000
tairyoku_2=0

for i in range(mini,maxi+1):
    tairyoku_2=0
    for j in x:
        tairyoku_2 += (j-i)**2
        
    tairyoku_1 = min(tairyoku_1,tairyoku_2)

print(tairyoku_1)
# スペース区切りの整数入力
N = int(input())

# スペース区切りの整数をリストに入力
x = [int(x) for x in input().split()]
x.sort()

cost_min = 10**20

for i in range(x[0],x[len(x)-1]+1):
    cost = 0
    for j in x:
        cost += (i-j)**2
    cost_min = min(cost_min,cost)

print(cost_min)
n = int(input())
x = list(map(int, input().split()))
av = round(sum(x)/n)
print(sum([(i-av)**2 for i in x]))
N = int(input())
X = list(map(int,input().split()))
ans = 10**9
for i in range(1,101):
    temp_ans = 0
    for j in X:
        temp_ans += (i-j)**2
    ans = min(temp_ans,ans)
print(ans)
N = int(input())
X = list(map(int,input().split()))

r = 0
a = round(sum(X)/N)
for x in X:
    r += (x - a)**2

print(r)
n = int(input())
x_list = list(map(int, input().split()))
ans_list = [sum([(x - p) ** 2 for x in x_list]) for p in range(min(x_list), max(x_list) + 1)]
print(sorted(ans_list)[0])
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

ans = (100 ** 2) * 100 + 1

_min = min(x)
_max = max(x)

for i in range(_min, _max + 1):
    tmp = 0
    for j in x:
        tmp += (j - i) ** 2
    ans = min(ans, tmp)

print(ans)
import numpy as np

N = int(input())
X = list(map(int, input().split()))
m = round(np.mean(X))
result = 0
for x in X:
    result += (x-m)**2
print(int(result))
N = int(input())
X = list(map(int, input().split()))
sum = 0
all = True
for a in X:
    sum = sum + a
C = int(sum / N + 0.5)
ans = 0
for b in X:
    ans = ans + (b-C)**2
print(ans)
N = int(input())
X = list(map(int, input().split()))

P = []
for i in range(min(X), max(X) + 1):
    HP = [(a - i)**2 for a in X]
    P.append(sum(HP))

print(min(P))
n = int(input())    
xl = list(map(int, input().split()))    
ans = 10**9

for i in range(1,101):
    v = 0
    for x in xl:
        v += (x-i)**2
    ans = min(ans,v)

print(ans)
n = int(input())
x = []
x = list(map(int, input().split()))

def E_sum(p):
    e_sum = 0
    for i in range(n):
        y = (x[i] - p)**2
        e_sum += y
    return e_sum

m = float("inf")
for j in range(1, 101):
    tmp = E_sum(j)
    if tmp < m:
       m = tmp

print(m)
n = int(input())
x = [int(x) for x in input().split()]
center = sum(x)//len(x)
center2 = center+1
ans, ans2 =0, 0
for i in x:
    ans += (i-center)**2
    ans2 += (i-center2)**2

print(ans) if ans<ans2 else print(ans2)
N=int(input())
X=sorted(map(int,input().split()))

ans=float("inf")
for P in range(X[0],X[-1]+1):
  a=0
  for i in range(N):
    a+=(X[i]-P)**2
  ans=min(ans,a)
  
print(ans)
N=int(input())
numbers =input().rstrip().split(" ")
points=[]
for i in range(1,101):
    summ=0
    for j in range(N):
        summ=summ+(int(numbers[j])-i)*(int(numbers[j])-i)
    points.append(summ)
print(sorted(points)[0])
n = int(input())
aaa = list(map(int, input().split(' ')))
center = sum(aaa) // n
ans = 99999999999999999
for i in [-1, 0, 1]:
  ans = min(ans, sum([(a - center + i) ** 2 for a in aaa]))
  
print(ans)
n = int(input())
xs = list(map(int, input().split()))
p = round(sum(xs) / n)
print(sum([(x - p)**2 for x in xs]))
N = int(input())
 
X = list(map(int, input().split()))
 
a = round((sum(X) / N), 3)
integer = int(a)
f = a - integer
 
if f < 0.5:
    P = integer
else:
    P = integer + 1
 
total = 0
for i in X:
    total += (i - P) ** 2
 
print(total)
n = int(input().rstrip())
xs = list(map(int, input().rstrip().split(' ')))

result = float('inf')

i = 0
while True:
    point = i + 1
    current_sum = sum([(x-point) * (x-point) for x in xs])
    if result > current_sum:
        result = current_sum
        i += 1
    else:
        break

print(result)
N=int(input())
List=list(map(int,input().split())) # 1行N列・・・Nは任意


List.sort()
sumList = [] # List初期化

for i in range(1,100):
	sumList.append(0)
	for j in List:
		sumList[i - 1] += (j - i)**2

sumList.sort()

print(sumList[0])
from functools import reduce
n = int(input())
X = list(map(int, input().split()))
minv =10000**2
for i in range(min(X),max(X)+1):
    minv = min(minv,sum((j-i)**2 for j in X))
print(minv)
N = int(input())
X = list(map(int,input().rstrip().split(" ")))
ans = 0
ansb = 0
for i in range(100):
  ansb = 0
  for i2 in range(N):
    ansb += (X[i2] - i)**2
  if i == 0 or ans > ansb:
    ans = ansb
print(ans)
N = int(input())
X = list(map(int,input().split()))
A = round(sum(X)/N)
T = 0
for i in range(N):
    T += (X[i]-A)**2
print(T)
N = int(input())
X = [int(x) for x in input().split()]

INF = (100 ** 2) * 100

minD = INF

for xi in range(1, 101):
    D = 0
    for n in range(N):
        D += (xi-X[n])**2
    if D < minD:
        minD = D

print(minD)
n = int(input())
x = list(map(int,input().split()))
dmin = 100000000
for i in range(min(x),max(x)+1):
  d = 0
  for j in x:
    d += (j-i)**2
  if d<dmin:
    dmin = d
print(dmin)
N=int(input())

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

X.sort()

min=10000000000
for P in range(100):

    power=0
    for j in range(len(X)):
        power=power+(X[j]-P)**2

    if power<=min:
        min=power

    P=P+1


print(min)
N = int(input())
X = list(map(int, input().split()))
M = round(sum(X)/N)
ans = 0
for i in X:
    ans+=(i-M)**2
print(ans)
def main():
    N = int(input())
    X = list(map(int, input().split()))
    ans = 10**11
    for i in range(0,101):
        temp = 0
        for x in X:
            temp += (x-i)**2
        ans = min(temp,ans)

    print (ans)


if __name__ == '__main__':
    main()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sys import stdin

n = int(input())
x_list_str = stdin.readline().rstrip().split()
x_list = [int(i) for i in x_list_str]

# 体力のリスト
sum_hp_list = []

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

if min_x == max_x:
    print(0)
    exit()

for i in range(min_x, max_x):
    sum_hp = 0
    for x in x_list:
        sum_hp += (x-i)**2
    sum_hp_list.append(sum_hp)

print(min(sum_hp_list))
n = int(input())
#a,b = map(int,input().split())
x_L = list(map(int,input().split()))

def destance(a,b):
    return (a-b)**2

x_L = list(sorted(x_L))
start = x_L[0]
end = x_L[-1]

ans = 10**20
for i in range(start,end+1):
    tmp = 0
    for k,val in enumerate(x_L):
        tmp += destance(x_L[k],i)
    ans = min(ans,tmp)
print(ans)
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
x = nl()

mn = 100100100
for p in range(101):
  cnt = 0
  for xi in x:
    cnt += (p-xi)**2
  mn = min(mn, cnt)
print(mn)
n = int(input())
x = list(map(int, input().split()))

min_ans = 1e9
for i in range(100):
    ans = sum([(i + 1 - j) ** 2 for j in x])
    min_ans = min(ans, min_ans)

print(min_ans)
N = int(input())

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

ans = float('inf')

for i in range(100):
  tmp = 0
  for x in X:
    tmp += (x-i) ** 2

  ans = min(ans,tmp)

print(ans)
import math

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

# max_p = max(x)
# min_p = min(x)

avg = math.ceil(sum(x)/n)
avg2 = sum(x)//n

ans = min(sum([(X-avg)**2 for X in x]), sum([(X-avg2)**2 for X in x]))

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

mi = min(xi)
ma = max(xi)
ans = 10**18
for i in range(mi, ma+1):
    num = 0
    for j in range(n):
        num += (xi[j]-i)**2
    ans = min(ans, num)
print(ans)
import math

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

ave = 0
ans1 = 0
ans2 = 0
for i in range(len(L)):
    ave += L[i]
ave = ave / len(L)
ave_under = math.floor(ave)
ave_up = math.ceil(ave)

for i in range(len(L)):
    ans1 += (L[i] - ave_under) ** 2
    ans2 += (L[i] - ave_up) ** 2
if ans2 > ans1:
    print(ans1)
else:
    print(ans2)
import math


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


mi_stamina = 1000000000
for i in range(-1000, 1000):
    def _distance(x):
        return (x-i)**2
    double_list = list(map(_distance, x_list))
    stamina = sum(double_list)
    if mi_stamina > stamina:
        mi_stamina = stamina

print(mi_stamina)
input = raw_input
n = int(input())

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

x_sum = sum(x_list)
x_ave = float(x_sum) / n

import math
m1 = int(math.ceil(x_ave))
m2 = int(math.floor(x_ave))
out1 = sum([(x-m1)**2 for x in x_list])
out2 = sum([(x-m2)**2 for x in x_list])
out = min(out1, out2)
print(out)
min_hp = 10 ** 7
n = int(input())
xs = list(map(int, input().split()))
for i in range(1, 101):
    min_hp = min(sum((x-i)**2 for x in xs), min_hp)
print(min_hp)
import statistics

N = int(input())
X = [int(i) for i in input().split()]
X.sort()
mid = statistics.mean(X)
ans = 0
ans1 = 0
ans2 = 0

for i in range(N):
    ans1 += (X[i] - int(mid)) ** 2
    ans2 += (X[i] - int(mid) - 1) ** 2
ans = min(ans1, ans2)

print(ans)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    X = list(map(int, input().split()))
    result = []
    for n in range(1, 100):
        tmp = 0
        for x in X:
            tmp += (x - n)**2
        result.append(tmp)
    print(min(result))


if __name__ == "__main__":
    main()
N = int(input())
X_ls = list(map(int, input().split(' ')))
rst = -1
for i in range(min(X_ls), max(X_ls) + 1):
    val = 0
    for j in X_ls:
        val += (i - j) ** 2
    if rst == -1:
        rst = val
    else:
        rst = min(rst, val)
print(rst)
import numpy as np
N   = int(input())
X   = np.array([int(x) for x in input().split()])
Pos = np.around(np.mean(X))
Min = int(sum(pow(X-Pos,2)))
print(Min)
n=int(input())
x=list(map(int,input().split()))
ans=[]

for i in range(1,101):
    y=0

    for j in range(n):
        y+=(x[j]-i)**2
    ans.append(y)
print(min(ans))
n=int(input())
xlist=list(map(int,input().split(" ")))
count=100000000000

for kaisai in range(101):
    sum=0
    for hito in xlist:
        sum+=(hito-kaisai)**2
    #print(sum)
    if sum<count:
        count=sum
print(count)
n = int(input())

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


total_ = 0
m = 100000000000000000000000000000000000

for i in range(100):
    for j in A:
        total_ += (j - i)**2
    if total_ < m:
        m = total_
    total_ = 0
print(m)
import numpy as np

N = int(input())
X = np.array(list(map(int, input().split())))
best_score = None
for i in range(np.min(X), np.max(X)+1):
    score = np.sum(np.power(X - i, 2))
    if best_score is None:
        best_score = score
    elif best_score > score:
        best_score = score
print(best_score)
n=int(input())
X=list(map(int,input().split()))
ans=-1
for i in range(1,101):
    cnt=0
    for x in X:
        cnt+=(x-i)**2
    if ans==-1:
        ans=cnt
    else:
        ans=min(ans,cnt)
print(ans)
n = int(input())
x = list(map(int,input().split()))
ans = 69*100**3
for i in range(101):
  tmp = 0
  for j in range(n):
    tmp += (i-x[j])**2
  ans = min(ans, tmp)
print(ans)
import numpy as np

def resolve():
    n = int(input())
    x = np.array(list(map(int, input().split())))

    ans = 1000000

    for i in range(100):
        ans = np.minimum(np.sum(np.square(x - i)), ans)

    print(ans)

resolve()
input()
xs = list(map(int,input().split()))
x_min = min(xs)
x_max = max(xs)
diss = []
for p in range(x_min,x_max+1):
    diss.append(sum([(p-x)**2 for x in xs]))
print(min(diss))
def main():
    n=int(input())
    xx=list(map(int,input().split()))
    m=None
    for i in range(1,101):
        mm=sum([(x-i)**2 for x in xx])
        if m is None or m>mm:
            m=mm
    print(m)
main()
N = int(input())
X = list(map(int, input().split()))

best = 10 ** 9
minx, maxx = min(X), max(X)
for p in range(minx, maxx + 1):
    tmp = 0
    for i in range(N):
        tmp += (X[i] - p) ** 2
    best = min(best, tmp)

print(best)
import numpy as np
N = int(input())
x = [int(i) for i in input().split() ]

each = 0
loss = 0
ll = []

for k in range(min(x), max(x)+1):
      for j in range(len(x)):
            each = np.power((x[j]-k), 2)
            loss += each
      ll.append(loss)
      loss = 0
  
print(min(ll))
import numpy as np
n = int(input())
x = np.array(list(map(int, input().split())))

ans = 10 ** 9
for i in range(1, 101):
    tmp = np.square(x - i).sum()
    ans = min(ans, tmp)

print(ans)
def calc(a):
    y = 0
    for xx in x:
        y += (a - xx) ** 2
    return y


n = int(input())
x = [int(i) for i in input().split()]
left = min(x)
right = max(x)
while (right - left > 1):
    l = calc(left)
    r = calc(right)
    if (l < r):
        right = (right + left) // 2
    else:
        left = (right + left) // 2
print(min(calc(left), calc(right)))
n = int(input())
x = list(map(int, input().split()))
ave = sum(x)//n
ans1 = 0
ans2 = 0
ans3 = 0
for i in x:
    ans1 += (i-ave)**2
    ans2 += (i-ave+1)**2
    ans3 += (i-ave-1)**2
print(min(ans1, ans2, ans3))
N = int(input())
X = list(map(int, input().split()))
Xsorted = sorted(X)
Xmax = max(X)
Xmin = min(X)
cnt = 0
l = list()

for i in range(Xmin, Xmax + 1):
  for j in range(N):
    cnt += (i - X[j]) ** 2
  l.append(cnt)
  cnt = 0
print(min(l))
n, *a = map(int, open(0).read().split())

ans = 1e18
for i in range(1, 101):
        tmp = 0
        for j in a: tmp += (j-i)**2
        ans = min(ans, tmp)
print(ans)
n=int(input())
X=list(map(int,input().split()))
sum=99999999

def f(i,X):
  sumf=0
  for j in X:
    sumf+=(j-i)**2
  return sumf

for i in range(min(X),max(X)+1):
  sum=min(sum,f(i,X))

print(sum)
N = int(input())
X = list(map(int,input().split()))
if sum(X)//N <= sum(X)/N <= sum(X)//N+0.5:
  A = sum(X)//N
else:
  A = sum(X)//N+1
B = []
for i in range(N):
  B.append((X[i]-A)**2)
print(sum(B))
import math

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

s = sum(x)

ans = 0
a = round(s/n)

for i in x:
  ans += (i - a) ** 2

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

Max = max(X)
p_min = 1000000000
for i in range(1, 101):
    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)
N = int(input())
X = list(map(int, input().split()))
ans = float('inf')
for i in range(1, 101):
    sumd = 0
    for x in X:
        sumd += (x - i) ** 2
    ans = min(ans, sumd)
print(ans)
from math import ceil, floor


def tai(X, p) -> int:
    return sum((X[i] - p) ** 2 for i in range(len(X)))


if __name__ == "__main__":
    N = int(input())
    X = [int(x) for x in input().split(" ")]
    print(min(tai(X, p) for p in range(-1, len(X) + 1000)))
n = int(input())
x = list(map(int, input().split()))
x.sort()

l = x[0]
r = x[-1]
S = 10 ** 9

for i in range(l, r+1):
    s = sum([(p-i)**2 for p in x])
    S = min(s, S)
print(S)
n=int(input())
x=list(map(int,input().split()))
p=sum(x)/n
p=round(p)
answer=0
for i in range(n):
    answer+=(x[i]-p)**2
print(answer)
import numpy as np
N = input()
X = np.array([i for i in map(int,input().split())])

print(int(np.sum((X-np.round(sum(X)/len(X)))**2)))
N = int(input())
X = list(map(int, input().split()))
k = sum(X) / N - 1 / 2
P = int(k) + 1

X = list(map(lambda x: (x - P)**2 ,X))
ans = sum(X)
print(ans)
n = int(input())
x = list(map(int,input().split()))
x.sort()
Sum = 0
Min = float("inf")
for i in range(100):
    Sum = 0
    for j in x:
        Sum += (j - i)**2
    if Sum < Min:
        Min = Sum
print(Min)
N = int(input())
X = list(map(int,input().split()))
A = []

for p in range(1,101):
  A+=[sum((x-p)**2 for x in X)]

print(min(A))
n = int(input())
x = list(map(int, input().split()))
ans = int(1e10)
for i in range(max(x)+1):
    cnt = 0
    for j in range(n):
        cnt += (x[j] - i) ** 2
    if ans > cnt:
        ans = cnt
print(ans)
n=int(input())
x=list(map(int,input().split()))
ans=9999999999
for i in range(min(x),max(x)+1):
    xi=list(map(lambda x:(x-i)**2,x))
    ans=min(ans,sum(xi))
print(ans)
N = int(input())
x = list(map(int, input().split()))
import numpy as np
x = np.array(x)
E = 10**9 #総和がこの値を超えることはない
for i in range(1, 101):
  e_tem = np.sum((x-i)**2)
  if e_tem < E:
    E = e_tem
print(E)
N = int(input())
X = list(map(int, input().split()))
result = -1
for i in range(1,101):
    st = 0
    for item in X:
        st += (item - i) ** 2
    if result == -1 or result > st:
        result = st
print(result)
N = int(input())
x = input().split()
avg = 0

for i in range (N) :
    x[i] = int(x[i])
    avg += x[i]

avg1 = avg // N
avg2 = avg // N + 1

ans1 = 0
ans2 = 0

for i in range (N) :
    ans1 += (x[i] - avg1) ** 2
    ans2 += (x[i] - avg2) ** 2

print (int(min(ans1 , ans2)))
n=int(input())
k=list(map(int,input().split()))
ap=float('inf')
for i in range(min(k),max(k)+1):
    ans=0
    for j in k:
        a=(j-i)**2
        ans+=a
    if ans<ap:
        ap=ans
print(ap)
N = int(input())
Xs = input()
Xlist = Xs.split(' ')
Xlist.sort()
anslist = []
if len(set(Xlist)) != 1:
    for P in range(int(Xlist[0]),int(Xlist[N - 1])+1):
        ans = 0
        for i in range(len(Xlist)):
            ans = ans + (int(Xlist[i]) - P)**2
        anslist.append(ans)
    print(min(anslist))
else:
    print(0)
n = int(input())
x = list(map(int, input().split()))
a = min(x) + (max(x) - min(x)) // 2
s = 1000000000000
for a in range(min(x), max(x)+1):
    s = min(s, sum(map(lambda x: (x - a) ** 2, x)))
print(s)
N = int(input())
X = list(map(int, input().split()))

ans = 1 << 30
for p in range(1, 101):
    sum = 0
    for x in X:
        sum += (x - p) ** 2
    ans = min(ans, sum)

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

ans = float("inf")

for i in range(1, 100):
    cnt = 0
    for j in X:
        cnt += (i-j)**2

    ans = min(cnt, ans)

print(ans)
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    X = list(map(int, input().split()))
    min = 10000000000
    for venue in range(1, 101):
        sum = 0
        for i in range(N):
            if sum > min:
                break
            # print((venue - X[i])**2)
            sum += (venue - X[i])**2
        if sum < min:
            min = sum
    print(min)

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

def main():

    N = int(sys.stdin.readline().rstrip())
    X = [int(x) for x in sys.stdin.readline().rstrip().split()]

    m = 100**2 * 100
    for p in range(101):
        tmp = 0
        for x in X:
            tmp += (x - p)**2
        m = min(tmp,m)

    print(m)


main()
N = int(input())
X = list(map(int, input().split()))
ans = []
for P in range(1, 101):
  wa = 0
  for x in X:
    wa += (x - P)**2
  ans.append(wa)
print(min(ans))
n = int(input())
persons_coordinates = list(map(int, input().split()))
max_coordinate = max(persons_coordinates)
min_coordinate = min(persons_coordinates)
min_stamina = float('inf')

for p in range(min_coordinate, max_coordinate + 1):
    stamina = 0
    for x in persons_coordinates:
        stamina += (x - p) ** 2
    if min_stamina >= stamina:
        min_stamina = stamina

print(min_stamina)
n=int(input())
arr=list(map(int,input().split()))
ans=10**18
for i in range(1,101):
  tmp=0
  for num in arr:
    tmp+=(i-num)**2
  ans=min(ans,tmp)
print(ans)
N = int(input())
zahyo = list(map(int, input().split()))
av= sum(zahyo) // len(zahyo)
av2 = sum(zahyo) / len(zahyo)

if av2 - av >= 0.5:
    av += 1

sumv = 0
for i in range(N):
    sumv += (zahyo[i] - av)**2
    
print(sumv)
import numpy as np

n = int(input())
x_list = list(map(int, input().split()))
x_list = np.array(x_list)

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

sum_min = 1e+9
for p in range(min_x, max_x+1, 1):
    sum = np.sum((x_list-p)**2)
    sum_min = min(sum_min, sum)
print(sum_min)
N = int(input())

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

x.sort()

s = 0
t = 0
for i in range(N):
    s += (x[i]-100)**2
    t += (x[i]-1)**2

s = max(s,t)

for i in range(1,100):
    a = 0
    for j in range(N):
        a += (x[j]- i)**2
    s = min(s, a)
    
print(s)
n=int(input())
A=list(map(int,input().split()))
x=round(sum(A)/n)
print(sum((a-x)**2 for a in A))
N = int(input())
X = list(map(int, input().split()))

mini = 10**10
for p in range(1, 101):
    used_hp = 0
    for x in X:
        used_hp += (x-p)**2
    mini = min(mini, used_hp)

print(mini)
def main():
    n = int(input())
    p = list(map(int,input().split()))
    q = round(sum(p)/n)
    ans = 0
    for i in p:
        ans += (i-q)**2
    print(ans)

if __name__ == '__main__':
    main()
N = int(input())
A = list(map(int, input().split()))
p = round(sum(A) / N)

print(sum([(a-p)**2 for a in A]))
N = int(input())
X = list(map(int, input().split()))
a = int(sum(X) / N)
b = a + 1
A, B = 0, 0
for x in X:
    A += (x - a) ** 2
    B += (x - b) ** 2
ans = min(A, B)
print(ans)
n = int(input())
x = [int(i) for i in input().split()]
p = round(sum(x) / n)
print(sum((i - p)**2 for i in x))
N = int(input())
X = list(map(int, input().split()))
sum_min = 10**8

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())
#N,K=map(int,input().split())
X=list(map(int,input().split()))
P=[]
for p in range(max(X)+1):
    a=0
    for x in X:
        a+=(p-x)**2

    P.append(a)

print(min(P))
n = int(input())
line = list(map(int, input().split()))
min_dist = 10**9
for i in range(max(line)+1):
  sum_dist = 0
  for j in range(n):
    sum_dist += (line[j] - i)**2
  if sum_dist < min_dist:
    min_dist = sum_dist
print(min_dist)
def main(N, X):
    def calc_cost(p):
        return sum((x-p)**2 for x in X)

    return min(map(calc_cost, range(max(X) + 1)))


if __name__ == "__main__":
    N = int(input())
    X = list(map(int, input().split()))
    ans = main(N, X)
    print(ans)
N = int(input())
x = list(map(int, input().split()))


max_x = max(x)
min_x = min(x)
sum_a = [0]*(max_x+1)


for i in range(0,max_x+1):
    for j in range(0,N):
        sum_a[i] += (x[j]-i)**2

#print(sum_a)
min_dis = min(sum_a)

check = min(sum_a)
ans = sum_a.index(check)
a = 0
for i in range(0,N):
    a += (x[i] - ans)**2

print(a)
N=int(input())
L=list(map(int,input().split()))
S=sorted(L)
ans=float("inf")
for i in range(S[0],S[-1]+1):
	tmp=0
	for j in range(N):
		tmp+=(S[j]-i)**2
	
	ans=min(ans,tmp)
print(ans)
N = int(input())
X = list(map (int, input().split()))
av = round(sum(X)/len(X))
ans = 0

for x in X:
  ans = ans + (av-x)**2
  
print(ans)
n = int(input())
x = list(map(int, input().split()))

sumlist = []

if len(set(x)) == 1:
    print(0)
else:
    for i in range(1, max(max(x), n)):
        s = 0
        for j in range(n):
            s += (x[j] - i) ** 2
        sumlist.append(s)

    if sumlist == []:
        print((x[0] - n) ** 2)
    else:
        print(sorted(sumlist)[0])
n=int(input())
X=list(map(int,input().split()))
R=100**2*100
for i in range(1,101):
    r=0
    for j in range(n):
        r+=(X[j]-i)**2
    R=min(R,r)
print(R)