peterverebics/CodeNet_Python_118 huggingface dataset:
N, *X = map(int, open(0).read().split())

ans = float("inf")
for p in range(1, 101):
    ans = min(ans, sum((x - p) ** 2 for x in X))

print(ans)
N = int(input())
X = list(map(int, input().split()))
A = []
for P in range(1,max(X)+1):
    for i in range(N):
        A.append((X[i]-P)**2)
    if sum(A[0:N]) <= sum(A[N:2*N]) or len(A) == N:
        A = A[0:N]
    else:
        A = A[N:2*N]
print(sum(A))
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    X = LI()

    ans = 10 ** 9

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

        if sum_temp <= ans:
            ans = sum_temp
    print(ans)


main()
n = int(input())
x = list(map(int,input().split(" ")))
x_max = max(x)
x_min = min(x)
l =[]

for i in range(x_min,x_max + 1):
    si = 0
    for j in range(n):
        xj = x[j]
        xj_p = (xj - i) ** 2
        si += xj_p
    l.append(si)

l.sort()
print(l[0])
N = int(input())
X = list(map(int, input().split()))
M = int(1e+9)
for i in range(max(X) + 1):
  S = 0
  for j in X:
    S += (j - i)*(j - i)
  if M > S:
    M = S
print(M)
N = int(input())
X = list(map(int, input().split()))
ans = float('inf')

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

min_=min(x)
max_=max(x)
ans=list()
for xy in range(min_, max_+1):
  life=0
  for xx in x:
    life+=(xx-xy)**2
  ans.append(life)
print(min(ans))
n = int(input())
x = list(map(int, input().split()))

min_cnt = 10000000

for p in range(1, 100):
    cnt = 0
    for i in range(n):
        cnt += (p - x[i])**2
    if min_cnt > cnt:
        min_cnt = cnt

print(min_cnt)
if __name__ == '__main__':
    n = int(input())
    x = list(map(int, input().split()))
    p = []

    for i in range(100):
        cnt = 0
        for j in range(n):
            cnt = cnt + (x[j]-i)**2
        p.append(cnt)

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

def main(N, lst_X):
    
    min_P1 = sum(lst_X) // N
    sum_sutamina1 = 0
    for X in lst_X:
        sum_sutamina1 += (X - min_P1) ** 2

    min_P2 = min_P1 + 1
    sum_sutamina2 = 0
    for X in lst_X:
        sum_sutamina2 += (X - min_P2) ** 2

    return min(sum_sutamina1, sum_sutamina2)
        
if __name__ == "__main__":

    answer = main(N, lst_X)
    print(answer)
N=int(input())
X=list(map(int,input().split()))
p=round(sum(X)/len(X))
ans=0
for i in range(len(X)):
    ans+=(X[i]-p)**2
print(ans)
n=int(input())
a=list(map(int,input().split()))
result=[]       
for i in range(0,102):
  count=0
  for j in range(n):
    count+=(a[j]-i)**2
  result.append(count)
print(min(result))
a = int(input())
b = input().split()
b = [int(j) for j in b]
x = round(sum(b) / a)
y = []
for i in range(a):
    y.append((x - b[i])**2)
print(sum(y))
n=int(input())
a=list(map(int,input().split()))
b=[i**2 for i in a]
#sum_=sum(b)-2*p*sum(a)+n*p**2
c=sum(a)
def tai(p):
    return n*p**2-2*p*c
d=[]
for i in range(min(a)-2,max(a)+2):
    d.append(tai(i+1))
print(min(d)+sum(b))
N=number=int(input())
X_list=list(map(int, input().split()))
min_pow=0
if N==1:
    print("0")
else:
    X_min=min(X_list)
    X_max=max(X_list)
    for i in range(X_min,X_max):
        sum_pow=0
        for j in range(N):
            sum_pow+=(X_list[j]-i)**2
        if i==X_min:
            min_pow=sum_pow
        if min_pow>sum_pow:
            min_pow=sum_pow
    print(min_pow)
N = int(input())
X = list(map(int, input().split()))
HP = set()
for p in  range(100):
    p += 1
    A = 0
    for i in range(N):
        A += (X[i] - p)**2
    HP.add(A)
print(min(HP))
n = int(input())
x = list(map(int, input().split()))
x_ans = round(sum(x)/len(x))
ans = 0
for i in x:
    ans += (i-x_ans)**2
print(ans)
N=int(input())
X=list(map(int,input().split()))
ANS=[0]*100
for i in range(100):
  for x in X:
    ANS[i] += ((x - (i+1)) ** 2)
print(min(ANS))
#ABC156 C - Rally

n = int(input())
x = [int(x) for x in input().split(' ')]
    
min_len =  100**2 * n

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

    min_len = min(min_len,all_len)

print(min_len)
# C
N = int(input())

X_list = list(map(int, input().split()))
mean_X = round(sum(X_list)/N)

res = 0
for x in X_list:
    res += (x - mean_X)**2

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

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

candidates = [sum(X) // N, sum(X) // N + 1]

ans = 0

a = 0
b = 0
for x in X:
    a += (x - candidates[0]) ** 2
    b += (x - candidates[1]) ** 2

if a < b:
    print(a)
else:
    print(b)
def main():
    N = int(input())
    X = list(map(int, input().split()))

    P = sum(X) // N
    ans1 = 0
    for x in X:
        ans1 += (x - P) ** 2
    ans2 = 0
    for x in X:
        ans2 += (x - (P + 1)) ** 2
    print(min(ans1, ans2))


if __name__ == "__main__":
    main()
# 初期入力
N = int(input())
X = list(map(int, input().split()))
X_max =max(X)
X_min = min(X)

tairyoku =[]
# Pで集会を開く
for P in range(X_min,X_max + 1): #住んでいるところで端から端まで確認
    tairyoku.append([(x_j - P)**2 for x_j in X ])
tairyoku_sum = [sum(i) for i in tairyoku ]
# print(tairyoku)
#print(tairyoku_sum)
print(min(tairyoku_sum))
N = int(input())
X = list(map(int, input().split()))

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

min_shouhi = 0
asn_zahyou = 0
for zahyou in range(lower, upper):
    shouhi = 0
    for i in range(N):
        shouhi += (X[i] - zahyou)**2
    
    if zahyou == lower:
        min_shouhi = shouhi
        asn_zahyou = zahyou
    else:
        if min_shouhi > shouhi:
            min_shouhi = shouhi
            asn_zahyou = zahyou

print(min_shouhi)
import math
N = int(input())
X = list(map(int,input().split()))
med = int(sum(X)/N + 0.5)
c = 0
for i in range(N):
  c += (X[i] - med)**2
print(c)
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
n = int(input())
xs = list(map(int,input().split()))
min_x = sum(xs) / n
x_z = Decimal(str(min_x)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
ans = 0
for i in xs:
    ans += (x_z - i)**2
print(ans)
n = int(input())
x = list(map(int,input().split()))

ans = 10000000

for i in range(100):
    result = 0
    for j in x:
        result += (j - i )**2
    ans = min(result, ans)
        
print(ans)
N=int(input())
X=list(map(int,input().split()))
re_X=int(round(sum(X)/N,0))
ans=0
for i in range(N):
    ans+=(X[i]-re_X)**2
print(ans)
import math

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

sX = sum(X)
kouho1 = math.ceil(sX / N)
kouho2 = sX // N
kouho3 = math.floor(sX / N)


ans1, ans2, ans3 = 0, 0, 0
for p in X:
    ans1 += (p - kouho1) ** 2
    ans2 += (p - kouho2) ** 2
    ans3 += (p - kouho3) ** 2

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

def cost_calc(list_x, p):
  cost = 0
  for x in list_x:
    cost += (x - p)**2
  return cost

cost = 10**20
for _ in range(min(list_x),max(list_x)+1):
  tmp = cost_calc(list_x, _)
  if tmp < cost:
    cost = tmp
print(cost)
n = int(input())
x = list(map(int, input().split()))
sumX = 0
for i in x:
    sumX += (i - round(sum(x)/n)) ** 2
print(sumX)
N = int(input())
X = list(map(int, input().split()))
X.sort()
r = None
for i in range(X[0], X[-1]+1):
    c = sum((m - i)**2 for m in X)
    if r is None or r > c:
        r = c

print(r)
n = int(input())
x = list(map(int, input().split()))
x_ave = sum(x) // n
def moment(val):
    list_init = [0]*n
    for i in range(n):
        list_init[i] = (x[i] - val)**2
    return(sum(list_init))

print(min(moment(x_ave), moment(x_ave + 1)))
N = int(input())
X = list(map(int,input().split()))
ans = 10**36
S = 0

for p in range(100):
    S =0
    for x in X:
        S += (x-p)**2
    ans = min(ans,S)

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

s=min(x)
b=max(x)

ans=100100100

for i in range(s,b+1):
    hp=0
    for j in x:
        hp+=(i-j)**2
    if hp<ans:
        ans=hp
print(ans)
n = int(input())
x = list(map(int, input().split()))
hpmin = (100 ** 2) * 100
for p in range(1, 101):
    hp = 0
    for j in range(n):
        hp += (x[j] - p) ** 2
    if hp < hpmin:
        hpmin = hp
print(hpmin)
N = int(input())
X = [int(x) for x in input().split()]
X.sort()
P = [[0 for i in range(N)] for _ in range(101)]
for p in range(101):
  for i, x in enumerate(X):
    P[p][i] = (x - p) ** 2
print(min([sum(p) for p in P[1:]]))
n = int(input())
x =list(map(int, input().split()))
xl = min(x)
xr = max(x)
ans = (xr-xl)**2*n
for i in range(xl,xr+1):
        ttl = 0
        for j in x:
            ttl+=(j-i)**2
        ans = min(ans, ttl)
print(ans)
N = int(input())
X = list(map(int, input().split()))

P = round(sum(X) / N)

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

print(ans)
n = int(input())
x = list(map(int,input().split()))
a = min(x)
b = max(x) + 1
ans = 10 ** 8
for p in range(a,b):
    m = 0
    for i in range(n):
        m += (x[i] - p) ** 2
    ans = min(ans,m)
print(ans)
def count(Xi):
    ans = 0
    for p in range(N):
        ans += (X[p]-Xi)**2
    return ans
    

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


for i in range(101):
    l.append(count(i))

print(min(l))
n=int(input())
x=list(map(int,input().split()))
ans=10**9
for i in range(1,101):
    s=0
    for j in x:
        s+=(i-j)**2
    ans=min(s,ans)
print(ans)
n,*a=map(int,open(0).read().split())
b=10**8
for i in range(1,101):
    b=min(b,sum((j-i)**2 for j in a))
print(b)
n = int(input())
xl = list(map(int, input().split()))
ans = 0
for x in xl:
  ans += (x-1)**2

for i in range(2, 101):
  tmp = 0
  for x in xl:
    tmp += (x-i)**2
  if tmp < ans:
    ans = tmp

print(ans)
import sys
import math
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

N = int(input())
X = list(map(int,input().split()))
ans = INF
for i in range(1, 101):
    temp = 0
    for l in X:
        temp += (l-i)**2
    if temp < ans:
        ans = temp
print(ans)
N = int(input())
lst = [int(x) for x in input().split(" ")]

min = 10000*N

lst.sort()

for i in range(lst[0],lst[-1]+1):
  x = 0
  for j in lst:
    x += (j-i)*(j-i)
  if x < min:
    min = x

print(min)
n = int(input())
l = list(map(int, input().split()))
ll = len(l)
res = 0
ans = 10000000000
 
for i in range(1, 101):
    for j in range(ll):
        res += (l[j] - i)**2
    ans = min(ans, res)
    res = 0
 
print(ans)
n=int(input())
x= list(map(int, input().split()))
ans=10**9
for i in range(min(x),max(x)+1):
    cost=0
    for j in x:
        cost+=(j-i)**2
    if cost<ans:
        ans=cost
print(ans)
import numpy as np
N=int(input())
X=np.array(list(map(int, input().split())))

MIN=100000000
for p in range(1,101):
  SUM=((X-p)**2).sum()
  if MIN>SUM:MIN=SUM
print(MIN)
_,x=open(0);print(min(sum((i-int(j))**2for j in x.split())for i in range(99)))
n = int(input())
(*x,) = map(int, input().split())
a = round(sum(x) / n)
print(sum(((i - a) ** 2) for i in x))
n=int(input())
a=input().split(" ")
num=[]
sum_list=[]
for i in range(n):
    num.append(int(a[i]))

num=sorted(num)

for i in range(num[0],num[n-1]+1):
    sum=0
    for j in range(n):
        dis=(num[j]-i)**2
        sum+=dis
    sum_list.append(sum)
sum_list=sorted(sum_list)
print(sum_list[0])
n = int(input())
x = list(map(int,input().split()))
x.sort()

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

ans = 10**15
for i in range(1, 101):
    v = 0
    for j in X:
        v += (j-i)**2
    ans = min(ans, v)

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

P = int(sum(X) / N + 0.5)
print(sum((x - P) * (x - P) for x in X))
n = int(input())
list = list(map(int, input().split()))

sum = 0
for i in list:
  sum += i
average = sum // len(list)


ans1 = 0
ans2 = 0
ans3 = 0
ans4 = 0
ans5 = 0
for i in list:
  ans1 += (i-average+1)*(i-average+2)
  ans2 += (i-average+1)*(i-average+1)
  ans3 += (i-average)*(i-average)
  ans4 += (i-average-1)*(i-average-1)
  ans5 += (i-average-2)*(i-average-2)
answer = min(ans1,min(ans2,min(ans3,min(ans4,ans5))))
print(answer)
n = int(input())
x = list(map(int, input().split()))
ans = []
for i in range(1, 101):
    tmp = 0
    for j in range(n):
        tmp += pow(x[j]-i, 2)
    ans.append(tmp)
print(min(ans))
N = int(input())
X = list(map(int,input().split()))

min_sum = 10000000000000000000000000000000000000

for j in range(0,100):
	tmp_sum = 0
	for i in range(N):
		tmp_sum += (X[i] - j) ** 2
	if tmp_sum < min_sum:
		min_sum = tmp_sum
	#print(tmp_sum)
print(min_sum)
n=int(input())
x=list(map(int,input().split()))
ans=100000000
for i in range(101):
    t=0
    for j in x:
        t+=(j-i)**2
    if ans>t:
        ans=t
print(ans)
import numpy as np
N=int(input())
X=list(map(int, input().split()))
X.sort()
Y=sum(X)/N
if Y-int(Y)>0.5:
    Y=int(Y)+1
else:
    Y=int(Y)
X=[(i-Y)**2 for i in X]
print(sum(X))
n = int(input())
x = list(map(int,input().split()))

point = sum(x)//n
sum1 = 0;sum2 = 0
for i in range(n):
    sum1 += (point - x[i])**2
    sum2 += (point+1 - x[i])**2
print(min(sum1,sum2))
n = int(input())
X = list(map(int, input().split()))

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

m1 = -(-sum(x) // len(x))
m2 = sum(x) // len(x)
ans1 = 0
ans2 = 0
for xi in x:
    ans1 += (xi - m1)**2
    ans2 += (xi - m2)**2

print(min(ans1, ans2))
n = int(input())
x = list(map(int, input().split()))
num = 10**10
for p in range(100):
    cnt = 0
    for i in range(n):
        cnt += (x[i] - p)**2
    num = min(num, cnt)
print(num)
from sys import stdin
input = stdin.readline


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

  min_ = float('inf')
  for p in range(1, 101):
    sum_ = 0
    for i in range(N):
      sum_ += (X[i] - p)**2
    min_ = min(min_, sum_)

  print(min_)


if(__name__ == '__main__'):
  main()
n = int(input())
x = [int(s) for s in input().split()]
hp = []
for i in range(min(x),max(x) + 1):
    sum_ = 0
    for j in x:
        sum_ = sum_ + (j - i)**2
    hp.append(sum_)
print(min(hp))
n = int(input())
x = list(map(int,input().split()))

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

print(min(ans))
n=int(input())
l= list(int(i) for i in input().split())
a=round(sum(l)/n)
k=0
for j in l:
  k+=(j-a)**2
print(k)
N = int(input())
X = list(map(int, input().split()))

ave = sum(X) / N

kouho1 = int(ave)

if ave != int(ave):
  kouho2 = kouho1 + 1
else:
  kouho2 = kouho1
  
def tairyoku(a):
  tai = 0
  for i in X:
    tai = tai + (i - a)**2
  return tai

tairyoku1 = tairyoku(kouho1)
tairyoku2 = tairyoku(kouho2)
print(min(tairyoku1, tairyoku2))
n = int(input())
x = list(map(int, input().split()))
avg = sum(x) / n
if avg % 1 >= 0.5:
    avg += 1
avg = int(avg)
ans = 0
for xi in x:
    ans += (xi - avg) ** 2
print(ans)
a=int(input())
lis=sorted(list(map(int , input().split())))
ans=float('inf')
ans2=0
for i in range(lis[-1]):
  for j in lis:
    ans2+=(j-(i+1))**2
  if ans>ans2:
    ans=ans2
  ans2=0
print(ans)
n = int(input())
x = list(map(int,input().split()))

phy = []
tmp = 0
max1 = 0
count = 0

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

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

print(max1)
# -*- coding: utf-8 -*-
n = int(input())
x = [int(i) for i in input().split()]

ans = 100 * 100 * 100
tmp = 0
for i in range(-1000, 1001): #iは集会を開く場所
    for j in range(n):
        tmp += pow(x[j] - i, 2)
    if ans > tmp:
        ans = tmp
    tmp = 0
print(ans)
N = int(input())
X = list(map(int, input().split()))
ans = 10**13
for i in range(1, 101):
    tmp = 0
    for xi in X:
        tmp += (xi - i) ** 2
    ans = min(tmp, ans)
print(ans)
import math

def main():
  N = int(input())
 # X = [int(input().split()) for _ in range(N)]
  X = list(map(int,input().split()))
  
  #住民がいる座標の最小値から最大値までで検討する
  start = min(X) 
  end = max(X)
  
  
  power = list()
  ans = 10000000000
  
  for i in range(start, end + 1):
    for n in X:
      power.append((i - n)**2)
    if ans > sum(power):
      ans = sum(power)
      
    power.clear()
    
  print(ans)
  
main()
n = int(input())
x = list(map(int,input().split()))

s = sum(x)
p = s / n
q = round(p)

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

print(r)
def main():
  from statistics import mean
  from math import floor,ceil

  n = int(input())
  x = list(map(int, input().split()))
  x_mean = mean(x) 
  if x_mean == 0.5:
      greater_than_x = len([i for i in x if i > x_mean])
      if greater_than_x * 2 >= n:
          x_mean = ceil(x_mean)
      else:
          x_mean = floor(x_mean)
  elif x_mean % 1 > 0.5:
      x_mean = ceil(x_mean)
  else:
      x_mean = floor(x_mean)
  x2 = [(num - x_mean)**2 for num in x]
  print(sum(x2))

main()
import numpy as np
N = int(input())
A = sorted(map(int, input().split())) 
P=round(sum(A)/len(A))
print(sum((np.array(A)-P)**2))
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
x = inl()
mn = 10**8
for p in range(1,101):
    sm = 0
    for j in range(n):
        sm += (x[j]-p)**2
    mn = min(mn,sm)
print(mn)
N = int(input())
X = list(map(int, input().split()))

avg = sum(X)/len(X)
avg=round(avg,0)

sum=0
for i in range(N):
    sum+=int((avg-X[i])*(avg-X[i]))
print(sum)
N = int(input())
Pi = [int(i) for i in input().split()]

avg = sum([i for i in Pi]) // N

r1 = sum([(avg - i)**2 for i in Pi])
r2 = sum([(avg +1 - i)**2 for i in Pi])

print(min(r1, r2))
# C - Rally
def main():
    N, *X = map(int, open(0).read().split())
    calc = lambda x, p: (x - p) ** 2
    left, right = min(X), max(X)
    ans = min(sum(calc(x, p) for x in X) for p in range(left, right + 1))
    print(ans)


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

P = round(sum(X)*1.0/N)

h = [(i - P)**2 for i in X]
print(sum(h))
from sys import stdin


def main():
    n = int(stdin.readline())
    x = list(map(int, stdin.readline().split()))

    p = sum(x) / n

    p1 = int(p)
    p2 = int(p + 1)

    s1 = 0
    s2 = 0

    for xi in x:
        s1 += (xi - p1) ** 2
        s2 += (xi - p2) ** 2

    print(min(s1, s2))


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

temp = 0
ans = []
for i in range(1,101):
    for j in range(N):
        temp += (X[j] - i) ** 2
        #print(temp)
    ans.append(temp)
    temp = 0
print(min(ans))
N = int(input())
X = list(map(int, input().split()))
P = sum(X) // N
result1 = 0
result2 = 0

for x in X:
  result1 += (x - P)**2
  result2 += (x - P - 1)**2

if result1 <= result2:
  result = result1
elif result1 > result2:
  result = result2


print(result)
n=int(input())
l=list(map(int,input().split()))
ans=float('inf')
for i in range(1,101):
    ans=min(ans,sum([(i-j)**2 for j in l]))
print(ans)
import math
n = int(input())
X = sorted(list(map(int, input().split())))
start = X[0]
end = X[-1]

ans = 10000000
for i in range(start, end+1):
    tmp = sum([(x-i)**2 for x in X])
    ans = min(tmp,ans) 
print(ans)
n = int(input()) 
x = list(map(int, input().split())) 
hp = []
sum = 0

for i in range(max(x)+1):
    for j in range(n):
        sum+=(x[j]-i)**2
    hp.append(sum)
    sum=0

print(min(hp))
inf = 1000000000

def main():
    n = int(input())
    num_list = list(map(int, input().split()))

    num_list.sort()

    ans = inf

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

    print(ans)

if __name__ == '__main__':
    main()
N = int(input())
Xinput = input().split()


X = [int(s) for s in Xinput]

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

Xout = [(x - Xmean) * (x - Xmean) for x in X]

print(sum(Xout))
n = int(input())
xlist = list(map(int,input().split()))

xlist.sort()
#max_x = xlist[n - 1]
#min_x = xlist[0]

#p = int((max_x - min_x)/2) + min_x

s = sum(xlist)
p = round(s / n)
add_x = 0
for i in range(n):
    add_x = add_x + (xlist[i] - p) ** 2

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

x_max, x_min = max(X), min(X)

min_cost = float('inf')
for p in range(x_min, x_max+1):
    cost = 0
    for j in range(N):
        cost += (X[j] - p) ** 2
    if cost < min_cost:
        min_cost = cost

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

x.sort()
ans = 0
min_ans = 10**9

for i in range(x[0],x[-1]+1):
    for j in range(len(x)):
        ans += (x[j]-i)**2
        
    if min_ans > ans:
        min_ans = ans
    
    ans = 0

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

ans = 1000000000
for P in range(min(X), max(X) + 1):
    S = sum([(Xi - P) * (Xi - P) for Xi in X])
    ans = min(ans, S)
print(ans)
# coding: utf-8
N = int(input())
X = [int(i) for i in input().split()]

X.sort()
s1 = sum([(X[i] - 1)**2 for i in range(N)])

c = 2
while c <= max(X):
    s2 = sum([(X[i] - c)**2 for i in range(N)])
    if s2 < s1:
        s1 = s2
    c += 1
print(s1)
N = int(input())
lis = list(map(int, input().split()))
P = []
for p in range(1,101,1):
  sum = 0
  for x in lis:
    sum += pow(x-p,2)
  P.append(sum)
print(min(P))
N = int(input())
X = input().split()

cog = 0
for i in range(0, N):
    cog += int(X[i])
    
cog = round(cog/N)
ans = 0
for i in range(0, N):
    ans += (int(X[i]) - cog)**2
print(ans)
n = int(input())
x = [i for i in map(int, input().split())]
s = 0

for i in range(n):
    s += x[i]
p = int(s/n)

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

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

print(s)
n = int(input())
x = list(map(int,input().split()))
answer = 0

for i in range(min(x),max(x)+1):
	result = 0
	for j in range(n):
		result += (x[j] - i) ** 2
	if answer == 0 or answer > result:
		answer = result
		number = i

print(answer)
num = int(input())
member = list(map(int, input().split()))
min_num = min(member)
max_num = max(member)
min_hp = 10000000
for i in range(min_num, max_num + 1):
    hp = 0
    for j in member:
        hp += (j - i) ** 2
    
    if hp < min_hp:
        min_hp = hp
print(min_hp)
n=int(input())
x=list(map(int,input().split()))
M=max(x)
l=[]
for i in range(M+1):
    a=0
    for j in range(n):
        a+=(x[j]-i)**2
    l.append(a)
print(min(l))
N = int(input())
X = list(map(int, input().split()))
M = round(sum(X)/N)
answer = 0
for i in X:
    answer += (i-M)**2
print(answer)
import sys

n = int(input())
xs = list(map(int, sys.stdin.readline().split()))
center = round(sum(xs) / n)
distances = [(center - x)**2 for x in xs]
ans = sum(distances)
print(ans)
n = int(input())
x = list(map(int, input().split()))
ans = float('inf')
for p in range(1, 101):
    res = 0
    for y in x:
        res += (p - y) ** 2
    ans = min(ans, res)
print(ans)
N = int(input())
*X, = map(int, input().split())

mn = min(X)
mx = max(X)

ans = []
hps = []
for i in range(mx + 1):
    for x in X:
        hps.append((x - i) ** 2)
    ans.append(sum(hps))
    hps = []

print(min(ans))
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, 1):
  cost = 0
  for j in range (n):
    cost += (x[j] - i) ** 2
  # print(cost)
  if cost < ans:
    ans = cost

print(ans)