peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
x = list(map(int,input().split()))
ans = 10**15

for i in range(1,101):
  r = 0
  for j in range(n):
    r += (x[j]-i)**2
  ans = min(ans,r)

print(ans)
N = int(input())
List = [int(i) for i in input().split()]


ans = 10**18
def rally(p):
    n = 0
    for a in range(N):
        n += (int(p)-List[a])**2
    return n

for i in range(1,101):
    ans = min(rally(i),ans)

print(ans)
s = [input() for i in range(2)]

n = int(s[0])
x = [int(s) for s in s[1].split()]

mina = 0
a = max(x)
b = min(x)
for i in range(b,a+1):
    tem = 0
    for j in range(n):
        tem += (x[j]-i)*(x[j]-i)
    if(i==b or tem<mina):
        mina = tem
print(mina)
n=int(input())
l=list(map(int,input().split()))
m=sum(l)/n
if m-int(m) < 0.5:
  m=int(m)
else:
  m=int(m)+1
print(sum([(k-m)**2 for k in l]))
N = int(input())
X = list(map(int, input().split()))
X = sorted(X)
avg = sum(X)//N
aa = []
for i in range(2):
  avg = avg + i
  a = 0
  for j in range(N):
    a += (X[j] - avg)**2
  aa.append(a)
print(min(aa))
n = int(input())
x = list(map(int, input().split()))

ans = 10**10
for i in range(101):
    t = 0
    for j in x:
        d = i-j
        t += d*d
    ans = min(ans, t)
print(ans)
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
x = round(S/N)
ans = 0
for i in range(N):
  ans += (A[i] - x)**2
print(ans)
N = int(input())
X = list(map(int,input().split()))
avg = sum(X)//N
sums_1 = 0
sums_2 = 0
for i in X:
    sums_1 += (avg - i)**2

for j in X:
    sums_2 += (avg+1 - j)**2


print(min(sums_1,sums_2))
n = int(input())
s = list(map(int,input().split()))
s.sort()
ans = 10**9
for i in range(101):
  sum = 0
  for j in s:
    sum += (i-j)**2
  if sum < ans: ans = sum
  else: break  

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

ans = 10 ** 10
for i in range(1, 101):
    hp = 0
    for x in X:
        hp += (x - i) ** 2
    ans = min(ans , hp)
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 range(N):
    cnt+=(X[j]-i)**2
  if ans>cnt:
    ans=cnt
print(ans)
n = int(input())
l = list(map(int, input().split()))
sl = []

ma, mi = max(l), min(l)
if ma == mi:
  sl.append(0)

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

print(min(sl))
import numpy as np
N = int(input())
X = list(map(int, input().split()))

def calc_energy(i, X):
    X = np.array(X)
    return sum((X-i)**2)

min_energy = 1000000000
min_ind = min(X)
max_ind = max(X)
for i in range(min_ind, max_ind+1):
   energy = calc_energy(i, X) 
   if energy < min_energy:
       min_energy = energy
print(min_energy)
N = int(input())
X = [int(i) for i in input().split()]
L, R = min(X), max(X)

ans = 10**1000
for i in range(L, R+1):
    box = 0
    for j in range(N):
        box += (X[j] - i)**2
    if ans > box:
        ans = box

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

list2 = []

o= len(list)
new_list = sorted(list)
max = new_list[o-1]

for i in range(max+1):
    t = sum((i-k)**2 for k in list)
    list2.append(t)

list3 = sorted(list2)

print(list3[0])
def main():
    n = int(input())
    x = list(map(int, input().split()))
    min = 10000000000
    for point in range(10000):
        s = sum([(i - point)**2 for i in x])
        if s < min:
            min = s
    print(min)


if __name__ == "__main__":
    main()
n=int(input())
x=list(map(int,input().split()))
m=1000000
for i in range(100):
    su=0
    for j in range(n):
        su+=(x[j]-i-1)**2
    if m>su:
        m=su
print(m)
n = int(input())
x = list(map(int,input().split()))
M = max(x)
s = [0]*(10*M)

for j in range(10*M):
	for i in range(n):
		s[j] += pow(x[i]-(j-5*M),2)
print(min(s))
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    X = [int(i) for i in readline().split()]

    m = sum(X) / N
    m = round(m)

    ans = 0
    for i in X:
        ans += (i - m)**2
    
    print(ans)


if __name__ == "__main__":
    main()
from operator import mul
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


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

    ans = INF
    x_min = min(X)
    x_max = max(X)
    for p in range(x_min, x_max + 1):
        tmp = 0
        for x in X:
            tmp += (x - p) ** 2
        ans = min(ans, tmp)
    
    print(ans)


if __name__ == '__main__':
    main()
n = int(input(), 10)
live_pos_list = list(map(int, input().split()))


def cost(live_pos, held_pos):
    return (live_pos - held_pos) ** 2

mean_pos = round(sum(live_pos_list) / n)
print(sum(map(lambda live_pos: cost(live_pos, mean_pos), live_pos_list)))
N = int(input())
X = list(map(int, (input().split())))

distance = lambda Xi, P: (Xi - P) ** 2

X_max = max(X)

answer = None
for P in range(1, X_max + 1):
    total = 0
    for Xi in X:
        total += distance(Xi, P)
    answer = min(total, answer) if answer is not None else total

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

for p in range(min(x), max(x)+1):
    sum = 0
    for i in x:
        sum = sum + (i-p)**2 
    hp.append(sum)
    
print(min(hp))
N = int(input())
X = [int(x) for x in input().split()]

y = sum(X)//N
c1 = 0
c2 = 0
for x in X:
    c1 += (x-y)**2
    c2 += (x-y-1)**2
print(min(c1, c2))
N=int(input())
A=list(map(int,input().split()))
P=(sum(A))//N
P0=P-1
P1=P+1
M,M1,M0=0,0,0
for i in A:
  M+=(i-P)**2
  M1+=(i-P1)**2
  M0+=(i-P0)**2
print(min(M,M1,M0))
#ABC156 - Virtual
sel='C'

#C
if sel=='C':
    def ceilT(a,b): #ceil(a/b)
        return (a+b-1)//b

    N=int(input())
    X=[int(i) for i in input().split()]
    p=ceilT(sum(X),N)
    ans=sum((x-p)**2 for x in X)
    p-=1
    ans=min(ans,sum((x-p)**2 for x in X))
    print(ans)
#!/usr/bin/env python
from collections import deque, defaultdict
import bisect


def comb(a, b):
    result = 1
    for i in range(b):
        result *= (a - i) / (i + 1)
    return result


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

    min_load = None
    for p in range(101):
        load = sum([(x - p) ** 2 for x in Xs])
        if min_load is None or min_load > load:
            min_load = load

    print(min_load)


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

p = round(sum(x)/n)

s = 0
for i in range(n):
  s += abs((x[i]-p))**2
  
print(s)
N = int(input())
X = list(map(int, input().split()))
X_min = min(X)
X_max = max(X)
S = []
if X_min == X_max:
    S.append(0)
for x in range(X_min, X_max):
    s = 0
    for i in range(N):
        s += (X[i]-x)**2
    S.append(s)
print(min(S))
import numpy as np
N = int(input())
X = np.array(input().split()).astype(int)
P = round(np.average(X))
print(int(np.sum((P-X)**2)))
n = int(input())
s = input().split()

sum = 0
for i in range(n):
  sum += int(s[i])

a = float(sum)/float(n)
if int(a)+0.5 <= a:
  a = int(a)+1
else:
  a = int(a)
  
ans = 0
for i in range(n):
  ans += (int(s[i])-a)**2

print(ans)
import numpy as np

n = int(input())
xs = list(map(int, input().strip().split()))
mn = min(xs)
mx = max(xs)
xs = np.array(xs)
diffs = np.empty((100, n), dtype=np.int)
for p in range(100):
    diffs[p] = xs - (p + 1)

ans = np.min(np.sum(diffs**2, axis=1))

print(ans)
import math

def calcEnergy(goal, curr):
  return (curr - goal) * (curr - goal)

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

xs = x.copy()
xl = x.copy()

av = (int(sum(x)/n))

for i in range(n):
  xs[i] = calcEnergy(av, xs[i])
  xl[i] = calcEnergy(av + 1, xl[i])

small = sum(xs)
large = sum(xl)
if(small < large):
  print(small)
else:
  print(large)
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(readline().rstrip())
X = list(map(int, readline().split()))

lower = min(X)
upper = max(X)

ans = float("inf")
for P in range(lower, upper+1):
    dis = 0
    for x in X:
        dis += abs(P - x) ** 2
    ans = min(ans, dis)
print(ans)
n = int(input())
l = list(map(int, input().split()))
m = 10**10
for p in range(1, max(l)+1):
    tmp = 0
    for x in l:
        tmp += (x-p)**2
    m = min(m, tmp)

print(m)
import numpy as np

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

minval = 1000000000000
ans=0
for candidate in range(101):
    tmp = sum((X-candidate)**2)
    if tmp < minval:
        minval=tmp
        ans = candidate

print(minval)
import numpy as np

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

average = np.mean(X)

m1 = int(average)
m2 = m1 + 1

ans1 = np.dot(X - m1, X - m1)
ans2 = np.dot(X - m2, X - m2)

print(min(ans1, ans2))
n = int(input())
x = list(map(int, input().split()))

# print(max(x))
# print(min(x))

tsukare = [0 for i in range(max(x)-min(x)+1)]

# print(tsukare)
# print(len(x))

for i in range(min(x), max(x)+1):
    for k in range(len(x)):
        tsukare[i-min(x)] += (i-x[k])**2

print(min(tsukare))
import numpy as np
 
N = input()
X = list(map(int, input().split()))
ans=9999999
for P in range(0, 101):
  sum = np.sum(list(map(lambda x: (x-P)**2, X)))
  ans = min(ans, sum)
    
print(ans)
N = int(input())
X = list(map(int, input().split()))
P = int(sum(X) / N) - 1
cost = []
for i in range(3):
    L = [(x - P) ** 2 for x in X]
    cost.append(sum(L))
    P += 1
print(min(cost))
N = int(input())
X = list(map(int,input().split()))

for p in range(1,101):
    total = 0
    for i in range(N):
        total += (X[i] - p) ** 2
    if p == 1:
        result = total
    elif total < result:
        result = total
print(result)
N = int(input())
X = list(map(int, input().split()))
P = round(sum(X)/N)
ans = sum(list(map(lambda x: (x-P)**2, X)))
print(ans)
N = int(input())
X = list(map(int,input().split()))
tmp = 0
mi =100000000000
for i in range(1,101):
  for k in range(N):
    tmp += (X[k] - i)**2
  if tmp < mi:
    mi = tmp
  tmp = 0
print(mi)
N=int(input())
*X,=map(int,input().split())

ans=10**9
i=1
while i<=100:
    j=0
    count=0
    while j<N:
        count+=(i-X[j])**2
        j+=1
    ans=min(ans,count)
    i+=1

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

m = 10 ** 6
for p in range(1,100):
    s = 0
    for i in range(N):
        s += (p-X[i])**2
    m = min(m,s)

print(m)
N = int(input())
Xlist = list(map(int, input().split()))
Xlist.sort()

a = sum(Xlist)/N

a_m = int(a)
a_p = a_m + 1

if a - a_m < a_p - a:
    p = a_m
else:
    p = a_p

ans = 0
for i in range(N):
    ans += (Xlist[i] - p)**2

print(ans)
n = int(input())
X = list(map(int, input().split()))
for p in range(101):
    sum = 0
    for x in X:
        sum += ((x - p)**2)
    if p == 0:
        ans = sum
    if ans > sum:
        ans = sum
print(ans)
import sys

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

for i in range(1, 100):
    hp = 0    
    for j in range(n):
        hp += (x[j] - i) * (x[j] - i)

    
    min_hp = min(hp, min_hp)
    
print(min_hp)
N=int(input())
X = list(map(int, input().split()))
X.sort()
p = X[0]
min_power = float('inf')
while p <= X[-1]:
  power = 0
  for x in X:
    power += pow((x-p),2)
  min_power = min(min_power, power)
  p += 1
print(min_power)
n = int(input())
x_list = list(map(int, input().split()))

min_count = 1e10
for i in range(101):
    count = 0
    for x in x_list:
        count += (x - i) * (x - i)
    if count < min_count:
        min_count = count

print(min_count)
n=int(input())
x=[int(i) for i in input().split()]
ans=10**9
for i in range(1,101):
    res=0
    for j in x:
        res+=(j-i)**2
    ans=min(ans,res)
print(ans)
import numpy as np
n = int(input())
x = np.array([int(i) for i in input().split()])
p = min(sum((x - np.floor(x.mean())) ** 2), sum((x - np.ceil(x.mean())) ** 2))
print(int(p))
N = int(input())
X = list(map(int, input().split()))
ans_list = []
tmp = 0
for i in range(1, max(X) + 1):
  tmp = 0
  for j in X:
    tmp += (j - i)**2
  ans_list.append(tmp)
print(min(ans_list))
N = int(input())
X = list(map(int,input().split()))
p = round(sum(X)/len(X))
print(sum([(x-p)**2 for x in X]))
N = int(input())
X = list(map(int,input().split()))

import numpy as np
arr = np.array(X)

ans = np.inf
for i in range(1,101):
    ans = min(ans, sum(map(lambda x:x**2,arr-i)))

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


Q=0
A=[]
for i in range(min(X),max(X)+1):
    for j in X:
        Q+=(j-i)**2
    A.append(Q)
    Q=0
print(min(A))
N = int(input())
X = list(map(int, input().split()))
tairyoku = [0]*100

for i in range(100):
    t=0
    for j in range(N):
        t += (X[j]-i)**2
        tairyoku[i]=t

print(min(tairyoku))
N = int(input())
X = list(map(int, input().split()))
X = sorted(X)

# print(N)
# print(X)

minX, maxX = min(X), max(X)
min_cost = 1e10

for p in range(minX, maxX + 1):
    cost = sum([(x - p) ** 2 for x in X])
    min_cost = min(min_cost, cost)

print(min_cost)
n = int(input())
x = list(map(int, input().split()))
ans = ((max(x)-min(x)))**2*n
for i in range(min(x),max(x)+1):
    t = 0
    for j in x:
       t+= (j-i)**2 
    ans = min(ans,t)
print(ans)
import numpy as np
import math
N = int(input())
X = np.array(list(map(int, input().split())))

P_floor = math.floor(np.sum(X)/N)
P_ceil = math.ceil(np.sum(X)/N)

ans = min(np.sum((X-P_floor)**2), np.sum((X-P_ceil)**2))

print(ans)
N = int(input())
X = list(map(int, input().split()))
Y = []
for x in range(100):
    y = [(X[i] - x)**2 for i in range(len(X))]
    Y.append(sum(y))
print(min(Y))
n = int(input())
x = list(map(int, input().split()))
minx = min(x)
maxx = max(x)
list = []
for i in range(minx,maxx+1):
  klist = []
  for j in x:
    k = (j-i)*(j-i)
    klist.append(k)
  #print(klist)
  list.append(sum(klist))
print(min(list))
import numpy as np
n = int(input())
x = list(map(int,input().split()))
x = np.array(x)
ans = 9999999
for i in range(1,101):
    ans = min(ans,sum((x-i)**2))

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

sum=0
for i in range(n):
  sum=sum+x[i]

if (sum/n)%1<=0.5:
  p=int((sum/n))
else:
  p=int((sum/n))+1
  
answer=0
for i in range(n):
  answer=answer+(x[i]-p)**2

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

ans = float('inf')
for i in range(1, 101):
    ans_i = 0
    for j in range(N):
        ans_i += (X[j] - i) ** 2
    ans = min(ans, ans_i)
print(ans)
n = int(input())
x = list(map(int, input().split()))

ans = 10**10

for j in range(1,101):
    tmp = 0
    for i in range(n):
        tmp += (j - x[i])**2
    ans = min(ans, tmp)

print(ans)
N = int(input())
X = sorted(list(map(int, input().split(" "))))
min = -1
for i in range(X[0], X[-1]+1):
  s = sum((x - i) ** 2for x in X)
  if min == -1:
    min = s
  if s < min:
    min = s
print(min)
N=int(input())
X=list(map(int,input().split()))
l=len(X)
s=10**10
for i in range(min(X),max(X)+1):
    x=[]
    for j in range(l):
        x.append((X[j]-i)**2)
    if s>sum(x):
        s=sum(x)
print(s)
if __name__ == '__main__':
	N = int(input())
	X = [int(x) for x in input().split()]

	ans = 10000000

	for i in range(1,101):
		s = 0
		for x in X:
			s += (x-i)**2

		if ans > s:
			ans = s

	print(ans)
n = int(input())
l = list(map(int, input().split()))
ans = 1000000
for p in range(1,101):
  d = 0
  for x in l:
    d += (x-p)**2
  ans = min(d,ans)
print(ans)
import math
N = int(input())
x = list(map(int,input().split()))

minimum = math.inf
for i in range(101):
    stamina = 0
    for j in range(N):
        stamina += (x[j]-i)**2
    minimum = min(minimum,stamina)

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

min_n = min(X_list)
max_n = max(X_list)
min_cost = 10**16

for n in range(min_n,max_n+1):
    cost = 0
    for x in X_list:
        cost = cost + (x - n)**2
    min_cost = min(min_cost, cost)

print(min_cost)
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    X=list(map(int,input().split()))
    ans=INF
    for i in range(1,101):
        tmp=0
        for n in X:
            tmp+=(n-i)**2
        ans=min(ans,tmp)
    print(ans)

if __name__ == '__main__':
    main()
n = int(input())
x = list(map(int,input().split()))
ans_list = []
for i in range(max(x)):
  ans = 0
  for j in x:
    ans += (j-(i+1))**2
  ans_list.append(ans)
print(min(ans_list))
def my_round(x, d=0):
    import math
    p = 10 ** d
    return float(math.floor((x * p) + math.copysign(0.5, x)))/p

def resolve():
    import statistics
    n = int(input())
    x = [int(i) for i in input().split()]
    median = my_round(statistics.mean(x))
    res = sum([(i-median)**2 for i in x])
    print(int(res))
    
resolve()
n = int(input())
x = [ int(x) for x in input().split() ]

s = sum(x)
avg = s // n

t = u = 0
for e in x:
    t += (e - avg)**2
    u += (e - (avg + 1))**2

print(min([t, u]))
n = int(input())
X = list(map(int, input().split()))

ans = 10 ** 9

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

for i in range(xmin, xmax + 1):
    tmp = 0
    for j in range(n):
        tmp += (X[j] - i) ** 2
    ans = min(ans, tmp)
print(ans)
N = int(input())
X = [int(i) for i in input().split()]

min_d = 10000000

for p in range(1,101):
    d = 0
    for x in X:
        d += (x-p)**2
    if d <= min_d:
        min_d = d
print(min_d)
N=int(input())
X=list(map(int,input().split()))
def P(n):
    return sum([(X[i]-n)**2 for i in range(0,N)])
l=[P(i) for i in range(1,101)]
print(min(l))
N = int(input())
X = list(map(int,input().split()))

def damage_all(X,P):
  damage = 0
  for i in X:
    damage += (i - P)**2
  return damage

P = round(sum(X) / len(X))
distance = damage_all(X,P)

print(distance)
from statistics import mean
import math
n = int(input())
citizen = list(map(int,input().split()))
hostF = math.floor(mean(citizen))
hostC = math.ceil(mean(citizen))
ansF = 0
ansC = 0
for i in citizen:
    ansF += (hostF-i)**2
    ansC += (hostC-i)**2
ans = ansF if ansF<ansC else ansC
print(int(ans))
n=int(input())
x=list(map(int,input().split()))
p=0
for i in range(n):
    p+=2*x[i]
  
p1=p//(2*n)
p2=p1+1

    
ans1=0
ans2=0
for j in range(n):
    ans1+=(x[j]-p1)**2
    ans2+=(x[j]-p2)**2
    
print(min(ans1,ans2))
n = int(input())
X = list(map(int, input().split()))

ans = float('inf')
for p in range(101):
    temp = 0
    for x in X:
        temp += (x-p)**2
    ans = min(ans, temp)
print(ans)
n = int(input())
x = list(map(int, input().split(' ')))
p = int(round(sum(x) / n))
r = 0
for i in x:
    r += (i - p) * (i - p)
print(r)
N = int(input())
X = list(map(int, input().split()))
a = 0
for i in range(N):
    a += X[i]
a /= N
a += 0.5
a = int(a)
ans = 0
for j in range(N):
    ans += (X[j]-a)**2
print(ans)
N = int(input())
cc = list(map(int,input().split()))
min_sum = float('inf')
for i in range(1,101):
  count = 0
  for j in cc:
    count += (i-j)**2
  min_sum = min(min_sum,count)
print(min_sum)
N = int(input())
X = list(map(int, input().split()))

ans = 10**9

for i in range(0, 101):
    tmp = 0
    for x in X:
        tmp += (x - i)**2
    ans = min(tmp, ans)

print(ans)
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n = ni()
l = nl()
print(min(sum((x-y)**2 for x in l) for y in range(101)))
import sys

n = int(input())

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

cofg=sum(x)//n
cofg2=cofg+1

sum=0
sum2=0
for i in range(n):
    sum+=(x[i]-cofg)**2
    sum2+=(x[i]-cofg2)**2


ans = sum if sum < sum2 else sum2



print(ans)
import sys

N = int(input())

line = input().split(" ")
X = []

for e in line:
	X.append(int(e))

ans = sys.maxsize
for P in range(101):
	curr = 0

	for x in X:
		curr += (x - P)**2

	ans = min(ans, curr)


print(ans)
N = int(input())
X = list(map(int, input().split()))
_min = min(X)
_max = max(X)
_sum = 1000000000
for i in range(_min, _max+1):
    temp = 0
    for x in X:
        temp += (x - i) * (x - i)
    if temp < _sum:
        _sum = temp
print(_sum)
N = int(input())
X = [int(a) for a in input().split()]

mi = 1<<100
for i in range(1, 101):
    mi = min(mi, sum([(x-i)**2 for x in X]))

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

total = 0
m = round(sum(X) / N)

for i in X:
    total += (m - i) ** 2
print(total)
N = int(input())
X = list(map(int,input().split()))

X_max = X[0]
X_min = X[0]

for i in range(N):
    if X_max < X[i]:
        X_max = X[i]
    if X_min > X[i]:
        X_min = X[i]

min = 0
count = 0
for p in range(X_min, X_max+1, 1):
    total = 0
    for i in range(N):
        total += (X[i]-p)**2
    count += 1
    if count == 1:
        min = total
    elif  min > total:
        min = total

print(min)
N = int(input())
X = list(map(int,input().split()))
ans = []
for i in range(min(X),max(X)+1):
    cnt = 0
    for j in X:
        cnt += (j-i)**2
    ans.append(cnt)#少なくとも1回は追加させるためこの位置にかく
        
print(min(ans))
import numpy as np
n=int(input())
X=list(map(int,input().split()))
X=np.array(X)
ans=10**100
for i in range(1,101):
  tmp=np.sum((X-i)**2)
  if tmp<ans:
    ans=tmp
print(ans)
N = int(input())
X = list(map(int, input().split()))
ans = 10 ** 7

for i in range(1, 101):#1から100で開催
  ans1 = 0
  for j in range(N):
    ans1 += (X[j] - i) ** 2
  ans = min(ans, ans1)
  
print(ans)
import numpy as np
N = int(input())
point_arr = np.array(list(map(int, input().split())))

mean = point_arr.mean()
int_mean = int(mean)

print(min(sum((point_arr-int_mean)**2), sum((point_arr-(int_mean+1))**2)))
# -*- coding: utf-8 -*-
n = int(input())
x = list(map(int, input().split()))
t = []
for p in range(1, 101):
    q = 0
    for j in x:
        q += (j-p)**2
    t.append(q)
print(min(t))
N = int(input())
R = list(map(int, input().split()))
ans = []

for j in range (1, 100):
    diff = 0
    sum = 0
    
    for i in range (N):
        diff = pow(R[i] - j, 2)
        sum += diff
    
    ans.append(sum)

print(min(ans))
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    m = 10 ** 9
    
    for i in range(1, 101):
        tmp = 0
        for j in range(N):
            tmp += (i - A[j]) ** 2 
        m = min(tmp, m)

    return m

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

xmin=min(xlist)
xmax=max(xlist)

min_answer=10**9
for i in range(xmin,xmax+1):
  answer=0
  for x in xlist:
    answer+=(x-i)**2

  min_answer=min(answer,min_answer)

print(min_answer)
N = int(input().strip())
X = sorted([int(v) for v in input().strip().split()])

c = 100000000000000000
for p in range(X[0], X[-1] + 1):
    P = sum([pow(x - p, 2) for x in X])
    if P >= c:
        break
    c = P
print(c)
# input
N = int(input())
X = list(map(int, input().split()))

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

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

print(ans)
# coding: utf-8
import math
import sys

N = int(input())
Xi = list(map(int, input().split()))
Xi.sort()
min = Xi[0]
max = Xi[N-1]
tmp = 0
result = sys.maxsize
for i in range(min,max+1):
    for j in range(0,N):
        tmp += (Xi[j] - i)**2
    if tmp <= result:
        result = tmp
    tmp = 0

print(result)
import numpy as np
N = int(input())
X = np.array(list(map(int, input().split())))
x = int(np.sum(X) / N + 0.5)
print(np.sum(np.square(X - x)))
n = int(input())
x = list(map(int, input().split()))
rec = []
for p in range(1,101):
    s = 0
    for i in x:
        s += (i-p)**2
    rec.append(s)
rec.sort()
print(rec[0])
N = int(input())
X = list(map(int, input().split()))
print(min(sum((x - P) ** 2 for x in X) for P in range(max(X) + 1)))
n=int(input())
x=list(map(int,input().split()))

for i in range(n):
    x[i]-=1

cost=[0]*100

for i in range(100):
    tai=0
    for j in range(n):
        tai+=(i-x[j])**2
    cost[i]=tai

print(min(cost))
n = int(input())
x = list(map(int,input().split()))
ans = []
for i in range(1,100):
    sum = 0
    for j in range(n):
        sum = sum +((x[j]-i)**2)
    ans.append(sum)
print(min(ans))
N = int(input())
R = list(map(int,input().split()))

min = 100000000
for i in range (100):
    sum = 0
    for j in range (N):
        sum += (R[j] - i)**2

    if sum <= min:
        min = sum
    
print(min)