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


MaxCoo = max(X)
MinCoo = min(X)
ave = (MaxCoo+MinCoo)//2
Range = MaxCoo-MinCoo
MinCost = 10**10
for i in range(Range//2):
    pos = ave+i
    cost = 0
    for member in X:
        cost += (member-pos)**2
    if cost < MinCost:
        MinCost = cost

    pos = ave-i
    cost = 0
    for member in X:
        cost += (member-pos)**2
    if cost < MinCost:
        MinCost = cost
print(MinCost)
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-j)**2
  ans = min(ans, tmp)
print(ans)
n = int(input())
x = list(map(int, input().split()))
x.sort()
ans = float("inf")
for i in range(x[0], x[-1]):
    t = 0
    for q in range(n):
        t += (i - x[q]) ** 2
    else:
        if ans > t:
            ans = t

print(ans)
line1 = input('')
line2 = input('')
n = int(line1)
xs = line2.split(' ')

min = 0
for p in range(1,101):
  sum = 0
  for x in xs:
    xi = int(x)
    d = (xi - p)*(xi-p)
    sum += d
  if min == 0:
    min = sum
  elif sum < min:
    min = sum

print(min)
def main():
    n = int(input())
    x = list(map(int, input().split()))
    
    ans_tmp = 10000000000000
    for j in range(n):
        ans = 0
        for i in range(n):
            ans += (x[i]-(j+1))**2

        if ans_tmp >= ans:
            ans_tmp = ans
    
    print(ans_tmp)

if __name__ == '__main__':
    main()
# input
N = int(input())
X = list(map(int, input().split()))

# check
ans = -1
for i in range(max(X)):
    sub_life = 0
    for j in X:
        sub_life += (j - i) ** 2

    if ans == -1 or ans > sub_life:
        ans = sub_life

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

Max = max(X)
p_min = 100000
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')
a = 0
for i in range(1,x[n-1]+1):
    for j in x:
        a += (j - i)**2
    ans = min(ans,a)
    a = 0
print(ans)
n = int(input())
h = list(map(int,input().split()))

mean = int(sum(h)/len(h))+1
#print(mean)
dist = 0
for i in range(len(h)):
    dist += (h[i]-mean)**2
print(dist)
a = int(input())
b = list(map(int, input().split()))
p = sum(b) // a

hp = 0
for i in b:
    hp += (i - p) ** 2

print(hp)
N = int(input())
X = list(map(int, input().split()))
small = 100000000
temp = 0

for p in range(1, 101):
  for i in range(N):
    temp += (X[i] - p)**2
    
  if temp < small:
    small = temp
    
print(small)
import numpy as np

def Rally(n, array):
    min_ = max(np.array(array)*1000000)
    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))
n = int(input())
x = list(map(int, input().split(' ')))
p = int(sum(x) / n)
r = 0
for i in x:
    r += (i - p) * (i - p)
print(r)
n=int(input())
x=[i for i in map(int, input().split())]
ans=1000000000000000000000000000000000000000
x.sort()
print(n,x)

for i in range(x[n-1]):
  cnt=0
  for k in x:
    cnt= cnt+(k-i)**2
  ans=min(ans,cnt)
print(ans)
import numpy as np
n = int(input())
a = np.fromstring(input(), dtype=np.int64, sep=" ")
result = int(np.ceil(a.var()*n))
print(result)
n = int(input())
x = [int(x) for x in input().split()]

max_n = 100000

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

    if sum <= max_n:
        max_n = sum

if len(set(x)) == 1:
    max_n = 0

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

a=sum(x)//n+1

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

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
n = int(input())
x = [int(x) for x in input().split()]

max_n = 100000

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

    if sum <= max_n:
        max_n = sum

print(max_n)
n = int(input())
x = input().split(' ')

p = 0
ans = []
while p <= int(x[n-1]):
  e = 0
  for i in range(n):
    e += (int(x[i])-p)**2
  ans.append(e)
  p+=1
print(min(ans))
n = int(input())
X = list(map(int,input().split()))
ans = 10**100
for i in range(1,101):
  count = 0
  for j in X:
    count += (i-j)*2
  ans = min(ans,count)
print(ans)
N = int(input())
X_list = [int(i) for i in input().split()]

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

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

if (minimum == 99999999999999) :
    print(high)
else :
    print(minimum)
n=int(input())
X=list(map(int,input().split()))
ans=float('inf')
for i in range(min(X),max(X)):
  now=0
  for x in X:
    now+=(i-x)*(i-x)
  ans=min(now,ans)
print(ans)
N = int(input())
A = list(map(int, input().split()))

tminm = 0
for k in range(N):
  tminm += (A[k] - 1)**2

ma = max(A)
for i in range(2,ma):
  minm = 0
  for j in range(N):
    minm += (A[j] - i)**2
  
  if minm < tminm:
    tminm = minm

print(tminm)
N=int(input())
X=list(map(int, input().split()))
 
ans =100000000000
tmp=0
cnt=0
 
for i in range(X[0],X[-1]+1):
    for j in range(len(X)):
        tmp += (X[j]-i)**2
    if ans > tmp:
        ans =tmp
    tmp=0
print(ans)
N=int(input())
X=list(map(int, input().split()))

ans =100000000000
tmp=0
cnt=0

for i in range(X[0],X[-1]+1):
    for j in range(len(X)):
        tmp += (X[j]-i)**2
    if ans > tmp:
        ans =tmp
        tmp=0
print(ans)
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
    p = 0
    for i in range(max(x)):
        k = i*(n*i - 2*sum(x))
        if k < minp:
            minp = k
            p = i
    print(sum(xx)-2*p*sum(x)+n*(p**2))
from math import ceil, floor


def tai(X, p):
    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(" ")]
    mean_x = sum(X) / N
    if mean_x == int(mean_x):
        print(tai(X, mean_x))
    else:
        print(min(tai(X, ceil(mean_x)), tai(X, floor(mean_x))))
n = input()
x = list(map(int,input().split()))
ans = 10000

#for i in range(min(x),max(x)+1,1):
i = min(x)
while i <= max(x):
    tmp = sum(map(lambda p: (p-i)**2,x))
    if ans > tmp:
        ans = tmp
    i += 1
print(ans)
n=int(input())
x=[i for i in map(int, input().split())]
ans=1000000000000000000000000000000000000000
x.sort()

for i in range(x[n-1]):
  cnt=0
  for k in x:
    cnt= cnt+(k-i)**2
  ans=min(ans,cnt)
print(ans)
import statistics
n=int(input())
x=[int(_) for _ in input().split()]
mid=int(statistics.mean(x))
mmid=mid-1
cnt=0
cntm=0
for i in range(len(x)):
  cnt+= (x[i]-mid)**2
  cntm+=(x[i]-mmid)**2
print(min(cnt,cntm))
N=int(input())
A=[int(x) for x in input().rstrip().split()]
ave=sum(A)//len(A)
ans=0
print(ave)
if N/2<(sum(A)%len(A)):
  ave+=1

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

max_x = max(x)
min_x = min(x)

ans = []
for i in range(1, 101):
  a = 0
  for xi in x:
    a += (xi - (i+1))*(xi - (i+1))
  ans.append(a)
  
print(min(ans))
n = int(input())
x = list(map(int, input().split()))

max_x = max(x)
min_x = min(x)

ans = []
for i in range(min_x, max_x+1):
  a = 0
  for xi in x:
    a += (xi - (i+1))*(xi - (i+1))
  ans.append(a)
  
print(min(ans))
N = int(input())
X = list(map(int,input().split()))
ans = 10**9+7
for i in range(max(X)):
  point = 0
  for j in X:
    point += ((j-i)**2)
  if point < ans:
    ans = point
print(ans)
N=int(input())
X=[int(s) for s in input().split()]

sum=0
Ans=10000000000000000000000000000000000000
Xmax=sorted(X)[N-1]

for i in range(Xmax):
    sum=0
    for j in range(N):
        sum+=(X[j]-i)**2
    Ans=min(Ans,sum)

print(Ans)
n = int(input())
x_lis = list(map(int, input().split()))
ans = 0
avg = int(sum(x_lis)/n)
for x in x_lis:
    ans += (x - avg-1)**2
print(ans)
n = int(input())
x = list(map(int, input().split()))
ans = int(1e10)
for i in range(max(x)):
    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()))

ma = max(x)
mi = min(x)
z = 0
a = []
for i in range(mi,ma+1):
    for j in range(n):
        y = (x[j] - (mi+i))**2
        z += y
    a.append(z)
    z = 0

print(min(a))
N,*X=map(int,open(0).read().split())
X.sort()
P = (sum(X)+X[0]) // N
ans=0
for i in X:
    ans += (i - P)**2
print(ans)
N = int(input())
A = list(map(int,input().split()))

c = sum(A)//N + 1
ans = 0
for i in range(N):
  ans += (A[i] - c) ** 2
print(ans)
n=int(input())
c=list(map(int, input().split()))

anc = float('inf')
tmp = 0
for p in range(min(c),max(c)):
    for i in c:
        tmp += (i-p)**2
    if tmp < anc:
        anc = tmp
    tmp = 0
print(anc)
n = int(input())
x = list(map(int, input().split()))

min_energy = None

for p in range(x[0], x[-1]+1):
    energy = 0
    for x_i in x:
        energy += (x_i - p) ** 2
    if min_energy is None:
        min_energy = energy
    else:
        min_energy = min(energy, min_energy)

print(min_energy)
N=int(input())
X=list(map(int,input().split()))
X.sort()
x_min=X[0]
x_max=X[N-1]
Min=10**10
for i in range(x_min,x_max):
    p=0
    for j in range(N):
        p+=(X[j]-i-1)**2
    if Min>p:
        Min=p
print(Min)
# C - Rally
# https://atcoder.jp/contests/abc156/tasks/abc156_c


p = int(input())
nums = list(map(int,input().split()))

total = 0


for num in nums:
    total += (num - p) ** 2

print(total)
N = int(input())
X = list(map(int, input().split()))
X_sum = sum(X)

if X_sum % N == 0:
    div = round(X_sum / N)
    ans = 0
    for i in range(N):
        ans += (X[i] - div) ** 2
    print(ans)
N = int(input())
List = list(map(int, input().split()))
s = 0
t = 0

for i in range(N):
  s += List[i]

ave = s/N

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

print(t)
import math
n = int(input())
x = list(map(int, input().split()))

#t = math.ceil(sum(x)/n)
t = sum(x)/n
ans = 0
for i in x:
  ans += abs((i-t))**2
print(math.ceil(ans))
n = int(input())
r = list(map(int, input().split()))
o = (max(r) + min(r)) // 2
old = 1000000000000000000000000
for x in range(o//2, max(r)):
  t = sum([(i - x) ** 2 for i in r])
  if t < old:
    old = t
print(old)
input()
x=list(map(int,input().split()))
r=10**9
for i in range(min(x),max(x)):
	s=0
	for j in x:
		s+=(i-j)**2
	r=min(r,s)
print(r)
n = int(input())
x = list(map(int, input().split()))

min_x = 100 * 100
for p in range(1, 100+1, 1):
  total = 0
  for xi in x:
    total += (xi - p) ** 2

  min_x = min([min_x, total])

print(min_x)
from sys import stdin

def main():
    N = int(stdin.readline().rstrip())
    l = list(map(int, stdin.readline().rstrip().split()))
    result = 1000000
    for i in range(0, max(l)):
        sum = 0
        for x in l:
            sum += (x - i)**2
        if result > sum:
            result = sum
    print(result)

if __name__ == '__main__':
    main()
# input
N = int(input())
X = list(map(int, input().split()))

# check
ans = 0
for i in range(1, max(X), 1):
    sub_life = sum([(j - i) ** 2 for j in X])

    if i == 1 or ans > sub_life:
        ans = sub_life

print(ans)
def main(n,x):
    if n == 1:
        return x[0]
    res = 10**31-1
    for point in range(min(x), max(x)):
        val = 0
        for i in range(len(x)):
            val += (x[i] - point)**2
        res = min(res, val)
    return res

n = int(input())
x = list(map(int, input().split()))
print(main(n,x))
N = int(input())
X = list(map(int,input().split()))

a = min(X)
b = max(X)

ans = []

for i in range(a-1,b):
  S = 0
  for j in range(N):
    S += (X[j]-i)**2

  ans.append(S)
  
print(min(ans))
import math

N = int(input())
X = list(map(int, input().split()))
cen = sorted(X)[int(-len(X)/2)]
sum = 0
all = True
for a in X:
    sum = sum + a
    for c in X:
            all = False
ans = 0
for b in X:
    ans = ans + (b-cen)**2
if all == True:
    ans = 0
    print(ans)
else:
    print(ans)
N = int(input())
X = list(map(int,input().split()))

INF = 10**7

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

X.sort()
ans = INF
for p in range(X[0],X[N-1]):
    sum = 0
    for i in range(N):
        sum += cost(X[i],p)
    ans = min(ans,sum)

print(ans)
N = int(input())
X = list(map(int, input().split()))
ans = 1000000
for i in range(max(X)):
    n = 0
    for j in range(N):
      n += (X[j]-i)**2
    if n < ans:
      ans = n
print(ans)
# 156-C
N = int(input())
X = [int(x) for x in input().split()]
cnt = 1
ans = 100000000
A = 0
while cnt <= 100:
  cnt += 1
  i = 0
  while i < N:
    A += (int(X[i])-cnt)*(int(X[i])-cnt)
    i += 1
  ans = min(ans, A)
  A = 0
print (ans)
n=int(input())
x=list(map(int,input().split()))

a=sum(x)/len(x)
c=0

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

print(int(c)+1)
n = int(input())
x = list(map(int, input().split()))
xmin = min(x)
xmax = max(x)
ans = 10**10
for i in range(xmin, xmax):
    tmp = [abs(i - x[j])**2 for j in range(n)]
    if sum(tmp) < ans:
        ans = sum(tmp)

print(ans)
import os
import math

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

    p = math.ceil(sum(x_list)/len(x_list))
    result = 0
    for i in range(num):
        result += pow((p - x_list[i]), 2)
    print(result)

if __name__ == "__main__":
    main()
def physical_strength(x,p):
  return pow((x - p), 2)



if __name__ == '__main__':
  num_resident = input()
  x_list = [int(a) for a in input().split()]
  min_x = min(x_list)
  max_x = max(x_list)
  
  fin_ps = pow(max_x, 2)
  for i in range(min_x, max_x):
    sum_ps = 0
    for x in x_list:
      sum_ps += physical_strength(x, i)
    if(sum_ps < fin_ps):
      fin_ps = sum_ps
  
  print(fin_ps)
n = int(input())
temp = list(map(int, input().split()))
rarry = 0
min = 100000007
min_temp = 0
for n_ in range(max(temp)):
    for i in temp:
        min_temp += ((i - n_) ** 2)
    #print(min_temp)
    if(min > min_temp):
        min = min_temp
    min_temp = 0


print("{}".format(str(min)))
n = int(input())
x = list(map(int, input().strip().split()))
alist=[]
pm=10e9
for p in range (min(x),max(x)):
    ans=0
    for xi in x:
        ans += (xi-p)**2

    if(ans<pm):
        pm=ans
print(pm)
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy


#X = str(input()).split()
#a = [int(x) for x in input().split()]


N = int(input())
X = [int(x) for x in input().split()]
ans = 9999999999
su = 0

X.sort()

xm = max(X)

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


print(ans)
import numpy as np

def main():
    N = int(input())
    A = sorted(map(int, input().split()))
    mean = np.mean(A)
    x = np.array(A) - mean
    print(int(np.dot(x, x)))

main()
n = int(input())
l = list(map(int,input().split()))
mini = 10000
for i in range(1, 101):
    l_sum = sum(list(map(lambda x: (x - i)**2, l)))
    if mini > l_sum:
        mini = l_sum
print(mini)
def atcoder2():
    a = [list(map(int,input().split())) for l in range(2)]

    n= a[0][0]
    x_l = a[1]

    P = sum(x_l)/n

    print(a,n)
    print(P)
    if P - int(P) >= 0.5:
        add= 1
    else:
        add = 0

    P = int(P)+add
    
    print(P)

    result = 0
    for Xi in x_l:
        result = result + (Xi-P)**2 

    print(result)
    return 


atcoder2()
import itertools

N = input()
# n, r = map(int, input().split())
# p = list(map(int, input().split()))
x = input().split()
# S = [int(input()) for i in range(int(n))]
summ =0
ave =0

for ii in x:
    ave+=int(ii)

ave = -(-ave // int(N))

for i in x:
    summ+= (int(i) - ave)**2

print(summ)
n = int(input())
x = list(map(int,input().split()))
ans = 10000
x.sort()
for p in range(x[0],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()))
d = [0]*(max(X)+1-min(X))
for i in range(min(X),max(X)+1):
  for x in X:
    d[i-min(X)] += (x-i-min(X))**2
  if i > min(X) and d[i-min(X)] >= d[i-1-min(X)]:
    print(d[i-1-min(X)])
    exit(0)    
print(min(d))
def main(n, xi):
    res = []
    for i in range(1,n+1):
        f = 0
        for j in xi:
            f += pow((i - j), 2)
        res.append(f)

    return min(res)

n = int(input())
xi = list(map(int, input().split()))
print(main(n,xi))
# -*- coding:utf-8 -*-
n = int(input())

PosList = []
TempSum = 0
ReturnSum = 0

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


for pos in range(max(PosList)):
    TempSum = 0
    for nPos in range(n):
        TempSum += (pos - PosList[nPos])**2
    if pos == 0:
        ReturnSum = TempSum
    elif ReturnSum > TempSum:
        ReturnSum = TempSum
    """
    print("Position = "+str(pos))
    print("TempSum = "+ str(TempSum))
    print("ReturnSum = " + str(ReturnSum))
    print("----------------------------")
    """

print(ReturnSum)
n=int(input())
l=list(map(int,input().split()))

mx=99999999999999999999999999
su=0
for i in range(n):
  su=0
  for j in range(n):
    su+=(l[j]-(i+1))*(l[j]-(i+1))
  if su<=mx:
    mx=su
print(su)
N = int(input())
X = list(map(int,input().split()))
ans = 10**10

for i in range(min(X),max(X)):
    cnt = 0
    for j in X:
        cnt += (j - i)**2
    ans = min(ans,cnt)
print(ans)
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 = math.ceil(sum(a) // n) + 1
ans = 0
for i in a:
    ans += (i - x) ** 2
print(ans)
import math
n=int(input())
x=list(map(int,input().split()))
y=[]
x_avr=sum(x)/n
for i in range(n):
    y.append(math.pow((x_avr-x[i]),2))
print(int(sum(y)+1))
N = int(input())
X = list(map(int,input().split()))
#ans = 10000
ls = []
for i in range(1,100):
    sum = 0
    for j in range(N):
        #sum += (X[j]-i)**2
        ls.append((X[j]-i)**2)
    #ans = min(ans,sum)
print(min(ls))
import numpy as np
import math
from statistics import median, mean


def main():
    n = int(input())
    x = list(map(int, input().split()))
    x.sort()
    avg = math.ceil((sum(x)/len(x)))
    result = 0

    if n % 2 == 0:
        med = median(x)
    else:
        med = median(x)

    for i in x:
        result += (i - avg) ** 2
    print(result)


if __name__ == "__main__":
    main()
n=int(input())
x=list(map(int,input().split()))

min_=min(x)
max_=max(x)

xy=round((min_+max_)/2)

ans=0
for xx in x:
  ans+=(xx-xy)**2

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

ans = 100 * 100
for i in range(101):
    power = 0
    for e in x:
        power += (e - i) ** 2

    ans = min(ans, power)

print(ans)
N=int(input())

x=list(map(int,input().split()))
mx=max(x)
a=[]
cal=0

for i in range(mx):
    for j in range(len(x)):
        cal+=(x[j]-i)**2

    a.append(cal)
    cal=0


print(min(a))
n=int(input())
x=list(map(int,input().split()))
x.sort()
def sump(x,p):
  s=0
  for a in x:
    s+=(a-p)**2
  return s
m=min(x)
M=max(x)
ans=[]
for p in range(m,M+1):
  ans.append(sump(x,p))
print(max(ans))
n = int(input())
x = list(map(int,input().split()))
Min,Max = min(x),max(x)
if Min == Max:
    print(Min)
    exit()
s = [0] * (Max - Min)
k = 0

for i in range(Min,Max):
    for j in x:
        s[k] += (j - i) ** 2
    k += 1
print(min(s))
N = int(input())
x = list(map(int,input().split()))
l = []
for i in range(N):
    ans = (x[i] - N) ** 2
    l.append(ans)
print(sum(l))
n = int(input())
x = list(map(int, input().split()))
min = 10000

for p in range(101):
    sum = 0
    for i in range(n):
        sum = sum + (x[i] - p)**2
    if  sum < min:
        min = sum

print(min)
n=int(input())
x=list(map(int,input().split()))
ans=0

sumx=sum(x)
if sumx%n==0:
  ave=sumx//n
else:
  ave=(sumx//n)+1
  
for i in range(n):
  ans+=(ave-x[i])**2
  
print(ans)
N=int(input())
X=list(map(int,input().split()))
E=[]
e=0
for i in range(min(X),max(X)+1):
    for j in range(len(X)):
        e+=(X[j]-i)**2
    E.append(e)
    e=0
print(E)
print(min(E))
N = int(input())
x = list(map(int, input().split()))
 
n = len(x)

sum_a = 0
sum_b = 0

for xi in x:
  sum_a += xi * xi
  sum_b += xi
  
ans = sum_a - (sum_b*sum_b)/n
print(int(ans+0.5))
import math

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

i = math.ceil(sum(X) / N)
s_sum = 0
for x in X:
    dd = (x - i) ** 2
    s_sum += dd

print(s_sum)
n = int(input())
xs = list(map(int, input().split(" "))) + list(range(100 - n))

for i in range(1, 100):
    print(sum([(xs[j] - i)**2 for j in range(n)]))
import numpy as np

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

tmp = np.array(num).mean() 
if tmp-int(tmp)<0.5:
    tmp=int(tmp)
else:
    tmp=int(tmp)+1
tmp

ans = 0
for i in num:
    ans += (i-tmp)**2
print(ans)
n=int(input())
x=list(map(int,input().split()))

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

print(m)
import math
import numpy as np
n= int(input())
l = list(map(int,input().split()))

ans = 0
me = int(round(np.mean(l)))
print(me)
for i in range(n):
  ans += (l[i]-me)**2
print(ans)
N = int(input())
X = list(map(int, input().split()))
sav = float("inf")
for i in range(min(X), max(X)):
    Xe = map(lambda x: abs(x - i) ** 2, X)
    health = sum(Xe)
    if sav > health:
        sav = health

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

p = int(sum(x_list)/n)

print(sum([(x - p)**2 for x in x_list]))
N = int(input())
x = list(map(int, input().split()))

p = sum(x) / N
p0 = p - int(p)

if p <= 0.5:
    p = int(p)
else:
    p = int(p) + 1

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

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

sum=0
A=[]

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

print(min(A))
N = int(input())
a = list(map(int,input().split()))
s = []
for i in range(1,101):
    b = sum((a[j]-i-1)**2 for j in range(N))
    s.append(b) 
print(min(s))
n = int(input())
X= [int(i) for i in input().split()]
X.sort()

ans = 10000
for p in range(1,101):
  sum =0
  for x in X:
    sum += (p-x)**2
    
  ans = min(ans,sum)
  
print(ans)
N = int(input())
X = tuple(map(int, input().split()))


MaxCoo = max(X)
MinCoo = min(X)
ave = (MaxCoo + MinCoo)//2
Range = MaxCoo-MinCoo+1
MinCost = 10**10
for i in range(Range//2):
    pos = ave + i
    cost = 0
    for member in X:
        cost += (member-pos)**2
    if cost < MinCost:
        MinCost = cost

    pos = ave - i
    cost = 0
    for member in X:
        cost += (member-pos)**2
    if cost < MinCost:
        MinCost = cost
print(MinCost)
# input
N = int(input())
X = list(map(int, input().split()))

# check
ans = 0
for i in set(X):
    sub_life = 0
    for j in X:
        sub_life += (j - i) ** 2
    
    if ans == 0 or ans > sub_life:
        ans = sub_life

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

mini, maxi = min(x), max(x)
min2, max2 = mini**2*n, maxi**2*n
ans = max2 if max2 > min2 else min2

for p in range(mini, maxi):
  suma = 0
  for z in x:
    suma += (z-p)**2
  if ans > suma:
    ans = suma
    
print(ans)
from statistics import mean, median,variance,stdev
n=int(input())
x=list(map(int,input().split()))

a=sum(x)//n+1
s=0
for i in range(n):
    s+=(x[i]-a)**2

print(s)
n = int(input())
a = list(map(int,input().split()))
HP = 0
minHP = float('inf')
for i in range(n):
    for j in range(n):
        HP += (a[j] - (i + 1)) ** 2
    if minHP > HP:
        minHP = HP
    HP = 0
print(minHP)
n = int(input())
x = list(map(int, input().split()))

ans = 10 ** 5
for p in range(min(x), max(x) + 1):
    cost = 0
    for xi in x:
        cost += (xi - p) ** 2
    ans = min(ans, cost)
print(ans)