Problem:
 Score : 300 points    Problem Statement There are N people living on a number line.  The i -th person lives at coordinate X_i .  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any integer coordinate . If you choose to hold the meeting at coordinate P , the i -th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.      Constraints  All values in input are integers.  1 \leq N \leq 100  1 \leq X_i \leq 100         Input Input is given from Standard Input in the following format:  N  X_1  X_2  ...  X_N       Output Print the minimum total stamina the N people have to spend.        Sample Input 1 2
1 4      Sample Output 1 5  Assume the meeting is held at coordinate 2 . In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.  Note that you can hold the meeting only at an integer coordinate.       Sample Input 2 7
14 14 2 13 56 2 37      Sample Output 2 2354

Solution (Python):
n = int(input())

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

min_hp = 0
sum_hp = 0

for i in range(n):
    sum_hp += (x[i]-1)**2
min_hp = sum_hp

sum_hp = 0
for i in range(2,max(x)+1):
    for j in range(n):
        sum_hp += (x[j]-i)**2
    if min_hp > sum_hp:
        min_hp = sum_hp
    sum_hp = 0
 
print(min_hp)

Solution (Python):
num = int(input())
address_list = [int(i) for i in input().split()]
meet_address_low = sum(address_list) // num
meet_address_high = meet_address_low + 1

diff_low = 0
diff_high = 0

for address in address_list:
    diff_low += (address - meet_address_low) ** 2
    diff_high += (address - meet_address_high) ** 2

print(min(diff_high, diff_low))

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]
ans = 1001001001
for i in range(min(x), max(x) + 1):
    ans = min(ans, sum((j - i)**2 for j in x))
print(ans)

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

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

Solution (Python):
n = int(input())
x_list = list(map(int, input().split()))
power_list = [0] * 100
def cost(p, q):
  return (p - q) ** 2
for i in range(100):
  for j in range(n):
    power_list[i] += cost(x_list[j], i)
print(min(power_list))

Solution (Python):
n=int(input())
l=list(map(int,input().split()))

s=min(l)
g=max(l)
ans=0
for k in range (n):
  ans+=(l[k]-s)**2

for i in range(s+1,g+1):
  hyp=0
  for j in range (n):
    hyp+=(l[j]-i)**2
  if hyp<ans:
    ans=hyp
    
print (ans)

Solution (Python):
N=int(input())
X=list(map(int,input().split(" ")))
P=min(X)
L=max(X)
sum1=0
for i in range(N):
  sum1+=(X[i]-P)*(X[i]-P)
while P!=L:
  sum2=0
  for i in range(N):
    sum2+=(X[i]-P-1)*(X[i]-P-1)
  if sum2<sum1:
    sum1=sum2
  P+=1
print(sum1)

Solution (Python):
n = int(input())
xs = list(map(int, input().split(' ')))

mn = min(xs)
mx = max(xs)
INF = float('inf')


result = INF
for p in range(mn, mx + 1):
    tmp = 0
    for x in xs:
        tmp += (p - x) ** 2
    if tmp < result:
        result = tmp

print(result)

Solution (Python):
n = int(input())
list_x = list(map(int, input().split()))
 

 
list_ans = []
 
for i in range(min(list_x), max(list_x)+1):
    
    
    ans = 0
    for j in list_x:
        ans += (i-j)**2
 
    list_ans.append(ans)
  
print(min(list_ans))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ave = sum(a)//n
b = sum([(i-ave)**2 for i in a])
c = sum([(i-ave-1)**2 for i in a])

print(min(b, c))

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

Solution (Python):
n = int(input())
X = list(map(int, input().split()))
low = min(X)
high = max(X)
ans = []

for p in range(low, high-low+1):
  dist = 0
  for x in X:
    dist += (x-p)**2
  ans.append(dist)
if len(ans) != 0:
  print(min(ans))
else:
  print(0)

Solution (Python):
n=int(input())
x=[int(i) for i in input().split()]
ans=10**10
for i in range(101):
  sum_=0
  for xx in x:
    sum_+=(xx-i)**2
  ans=min(sum_,ans)
print(ans)

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
x=sorted(x)

li=[]

for p in range(x[0],x[-1]+1):
  hp=0
  for q in x:
    hp+=(p-q)**2
  li.append(hp)
print(min(li))

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

ave = sum(X) // N

anss = []
for P in [ave-1, ave, ave+1]:
    anss.append(sum([(P-x)**2 for x in X]))

print(min(anss))

Solution (Python):



X=[]
N=int(raw_input())
X=map(int,raw_input().split())

kotae=0
for p in range(min(X),max(X)+1):
    karioki=0
    for i in range(N):
        karioki+=pow(X[i]-p,2)
    if(p==min(X)):
       kotae=karioki
    elif(kotae>karioki):
         kotae=karioki
print kotae

Solution (Python):
n = int(input())
ylist = list(map(int,input().split()))
p = list(range(0,max(ylist)+1))
anslist = []
for i in p:
  ansl = sum((p[i]-ylist[j])**2 for j in range(0,n))
  anslist.append(ansl)
print(min(anslist))

Solution (Python):
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)

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

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

Min_power = 0

for i in X:

    Min_power += (i-x_min)**2


for p in range(x_min, x_max+1):
    power = 0
    for i in X:
        power += (i-p)**2
    if Min_power > power:
        Min_power = power

print(Min_power)

Solution (Python):
import sys

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()

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

ans = None
for i in range(X[0], X[-1] + 1):
    dist = sum((i - j) ** 2 for j in X)
    if ans is None or dist < ans:
        ans = dist
print(ans)

Solution (Python):
N=int(input())
X=list(map(int,input().split()))
ans=float('inf')

for P in range(1,101):
  value=0
  for i in X:
    value+=(i-P)**2
  ans=min(ans,value)

print(ans)

Solution (Python):
n = int(input())
xs = list(map(int, input().split()))



ans = 1000000000000
i = 0
while i < 100:
  sum = 0
  for x in xs:
    sum += (x - i)**2
  if sum < ans:
    ans = sum
  i += 1

print(ans)

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

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

Solution (Python):
import math

N = int(input())
lst = [int(x) for x in input().split()]
a = sum(lst) / N
b = math.ceil(a)
c = math.floor(a)
ret1 = sum([(b - x) ** 2 for x in lst])
ret2 = sum([(c - x) ** 2 for x in lst])

print(min(ret1, ret2))

Solution (Python):

N = int(input())
num = input().split()
max_num =max(num)
temp = []



for i in range(100):
  sum = 0
  for a in num:
    out = (i - int(a))** 2
    sum += out
  temp.append(sum)

min_temp=min(temp)
print(min_temp)

Solution (Python):
n = int(input())
x = list(map(int,input().split()))
cost = []
for i in range(100):
  tmp = 0
  for j in x:
    tmp += (j - i) ** 2
  cost.append(tmp)
cost.sort()
print(str(cost[0]))

Solution (Python):
n = int(input())
x = list(map(int,input().split()))
ans = list()
for p in range(1,101):
  v_sum = 0
  for i in x:
    v_sum += (p - i)**2
  ans.append(v_sum)
print(min(ans))

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

avg = round(sum(X)/len(X))
Y = [(x-avg)**2 for x in X]
print (sum(Y))

Solution (Python):

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

s = []
for pos in range(min(x_lis),max(x_lis)+1):

    tir = []
    for x in x_lis:
        tir.append((x - pos)**2)
    s.append(sum(tir))
        

print(min(s))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
def EN(x):
  return sum([(x-a)**2 for a in A])
m = EN(1)
for i in range(2, 101):
  if EN(i) <= m:
    m = EN(i)
  else:
    break
print(m)

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

ans = []
count = 0

for i in range(0,101):
    number = 0
    count = 0
    for j in X:
        number = number + ((j-i)**2)
        count = count + 1
        if N == count:
            ans.append(number)

print(min(ans))

Solution (Python):
def listint():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
def getint():
    a = input()
    a = int(a)
    return a
def main(n,x):
    ans = 10000000
    for i in range(100):
        sumup = 0
        for j in range(n):
            sumup = sumup + (x[j] -i)*(x[j]-i)
        if sumup < ans:
            ans = sumup
    return ans
        
n = getint()
x = listint()
ans = main(n,x)
print(ans)

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
 
ans=10**10
for i in range(0,101):
  tmp=0
  for x in X:
    tmp += (i - x)**2
  
  if ans>=tmp:
    ans=tmp
 
print(ans)

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]
ave = sum(x) // n
ans1 = 0
ans2 = 0
for i in range(n):
    ans1 += (x[i] - ave) ** 2
    ans2 += (x[i] - (ave + 1)) ** 2
print(min(ans1, ans2))

Solution (Python):
n=int(input())
a=[int(j) for j in input().split()]
ans=10**18
for i in range(101):
    tmp=0
    for j in a:
        tmp+=(i-j)**2
    ans=min(ans,tmp)
print(ans)

Solution (Python):

import sys


def solve(N: int, X: "List[int]"):
    X.sort()
    sum=0
    for i in X:
        sum+=i**2
    tempsum=0
    for p in range(X[0],X[N-1]+1):
        temp=0
        for j in range(N):
            temp+=p**2-2*p*X[j]
        tempsum=min(tempsum,temp)
    print(sum+tempsum)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    X = [int(next(tokens)) for _ in range(N)]  
    solve(N, X)

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
L = [a for a in map(int,input().split())]
K = max(L)
Power = []
for i in range(1,K+1):
  add = 0
  for j in range(len(L)):
    add+= (i - L[j])**2
  Power.append(add)
print(min(Power))

Solution (Python):

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

ret=float("inf")
for i in range(1,101):
    ret = min(ret,sum(list(map(lambda y:(i-y)**2,x))))
print(ret)

Solution (Python):
n = int(input())
X = list(map(int, input().split()))
ans = float('inf')
for x in range(1, 101):
    tmp = sum( [ (y-x)**2 for y in X ] )
    ans = min(tmp, ans)
print(ans)

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
l = []
for i in range(1, 101):
  cnt = 0
  for j in x:
    cnt += (j - i) ** 2
  l.append(cnt)
print(min(l))

Solution (Python):
from sys import stdin
import math

n = int(stdin.readline().rstrip())
x = [int(x) for x in stdin.readline().rstrip().split()]

result = 999999999
for i in range(100):
    sum = 0
    for xx in x:
        sum += (xx - i) * (xx - i)
    if sum < result:
        result = sum

print(result)

Solution (Python):
a = int(input())
li = list(map(int,input().split()))	
b = sum(li)
c = b / a
an = round(c)
n = 0
ans = 0
for i in range(a):
  d = (li[n] - an) ** 2
  ans += d
  n += 1
print(ans)

Solution (Python):
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)

Solution (Python):
def p(x,n,s):
    return int(n*((x-s/n)**2)-(s**2)/n)

n=int(input())
l=list(map(int,input().split()))
s=sum(l)
ds=0
for num in l:
    ds+=num**2
ans=ds+min(p(s//n,n,s),p(s//n+1,n,s))
print(ans)

Solution (Python):
N = int(input())
X = tuple(map(int,input().split(" ")))
ans = 2**60
for p in range(1,101):
    tmp = 0
    for x in X:
        tmp += (x-p)**2
    ans = min(ans,tmp)

print(ans)

Solution (Python):
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    
    ans = 10 ** 9
    for i in range(A[0], A[-1]+1):
        c = 0
        for a in A:
            c += (abs(a-i)) ** 2
        ans = min(ans, c)
        
    return ans

print(solve())

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
x.sort()
m=10**6
for p in range(min(x),max(x)+1):
	m=min(sum([(i-p)**2 for i in x]),m)
print(m)

Solution (Python):
n = int(input())
x = list(map(int,input().split()))
x = sorted(x)
m = 10**20
for p in range(x[0],x[n-1]+1):
    power = 0
    for i in range(n):
        power += (x[i]-p)**2
    m = min(m,power)
print(m)

Solution (Python):
n=int(input())
arr=list(map(int,input().split()))
arr.sort()
sum=10e9
for i in range(1,101):
  cnt=0
  for j in range(n):
    cnt+=(arr[j]-i)**2
  sum=min(cnt,sum)
print(sum)

Solution (Python):
import numpy as np

n = int(input())
x = list(map(int, input().split()))
x = sorted(x)
min = np.inf

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

print(min)

Solution (Python):
import numpy as np
N = input()
X = input().split()
X = np.array(X).astype(int)
xx = []
for p in range(100):
    xx.append(((X-p)**2).sum())
print(min(xx))

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

def loss(y):
    return sum([(x-y)**2 for x in X])
 
print(min([loss(i) for i in range(1, 101)]))

Solution (Python):
import math

N = int(input())
X = list(map(int, input().split()))
max_xi = max(X)
min_xi = min(X)
ans = int(math.pow(99, 2)) * 100
for p in range(min_xi, max_xi + 1):
    total = 0
    for xi in X:
        total += int(math.pow(xi - p, 2))
    ans = min(ans, total)
print(ans)

Solution (Python):
N=int(input())
S=list(map(int,input().split()))
memo=[]
for i in range(min(S)-100,max(S)+100):
    summ = 0
    for j in range(0,N):
        summ+=(i-S[j])**2
    memo.append(summ)

print(min(memo))

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
t = 10 ** 9 + 7
for i in range(101):
  c = i
  tt = 0
  for j in range(n):
    tt += ((x[j] - c) ** 2)
  t = min(t, tt)
print(t)

Solution (Python):
n = int(input())
arrx = list(map(int,input().split()))
sumx = sum(arrx)
small = int(sumx // len(arrx))
big = int(-(-sumx // len(arrx)))
smallans = 0
bigans = 0
for x in arrx:
  smallans += (x-small)**2
  bigans += (x-big)**2
print(min(smallans,bigans))

Solution (Python):
N=int(input())
X=[int(x) for x in input().split()]
a=int((sum(X)+N/2)//N)
print(sum([(x-a)**2 for x in X]))

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, X: "List[int]"):
    ans = INF
    for i in range(1, 101):
        t = 0
        for j in range(N):
            t += (X[j]-i)**2

        ans = min(ans, t)

    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    X = [int(next(tokens)) for _ in range(N)]  
    solve(N, X)

if __name__ == '__main__':
    main()

Solution (Python):
import math
flr = int(input())
inp = input().split()
n = len(inp)
m = int(max(inp))
num = 1
l = []
for i in range(m):
	total = 0
	i = 0
	for i in range(n):
		N = int(inp[i])
		i += 1
		col = (N-num)**2
		
		total += col
	l.append(total)
	num += 1
print(min(l))

Solution (Python):




def solve(inp):
    N = int(inp.readline().strip())
    X = list(map(int, inp.readline().strip().split(' ')))

    r = 999999999999
    for i in range(1, max(X) + 1):
        s = sum(map(lambda x: abs(i - x) * abs(i - x), X))
        r = min(r, s)

    return str(r)


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()

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

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

ans = 1000000

for n in range(a, b + 1):
    sum = 0
    for x in X:
        sum += (x-n)*(x-n)
    ans = min(ans, sum)
print(ans)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    a = LI()
    r = inf
    for i in range(1,101):
        t = 0
        for x in a:
            t += (x-i) ** 2
        if r > t:
            r = t

    return r


print(main())

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
t = round(sum(x) / n)
p = 0
for i in x:
    p += ((i-t)**2)
print(p)

Solution (Python):
n= int(input())
x_list=list(map(int, input().split()))
power = []
for i in range(1,101):
  power.append(0)
  for j in x_list:
    power[i-1] += ((j - i) ** 2)
print(min(power))

Solution (Python):
n=int(input())
seq=input().split()
nseq=[]
for i in range(n):
    nseq.append(int(seq[i]))
M=max(nseq)
m=min(nseq)
hp=(M-m)*(M-m)*n
for i in range(m,M+1):
    s=0
    for j in range(n):
        s+=(nseq[j]-i)*(nseq[j]-i)
    hp=min(hp,s)
print(hp)

Solution (Python):
n=int(input())
seq=input().split()
s=0
for i in range(n):
    s+=int(seq[i])
ave=round(s/n)
hp=0
for i in range(n):
    hp+=(int(seq[i])-ave)*(int(seq[i])-ave)
print(hp)

Solution (Python):
def resolve():
    n = int(input())
    x = list(map(int, input().split()))
    rs = 10**10
    for i in range(1,101):
        x1 = x
        x2 = list(map(lambda x:x-i, x1))
        x3 = list(map(lambda x:x**2, x2))
        x3 = sum(x3)
        if rs > x3:
            rs = x3
    print(rs)
resolve()

Solution (Python):
import sys

n = int(input())
pos = input().split()


xmin = int(min(pos))
xmax = int(max(pos))

for ii in range(xmin, xmax+1):
    
    nowmax = 0

    for p in pos:
        nowmax = nowmax + pow((ii - int(p)),2)

    nextmax = 0
    for p in pos:
        nextmax = nextmax + pow(((ii+1) - int(p)),2)

    if nextmax >= nowmax:
        print(nowmax)
        sys.exit()

Solution (Python):
n = int(input())
x = list(map(int,input().split()))
x.sort()
ans = 10**9
for i in range(1,x[-1]+1):
    energy = 0
    for j in x:
        energy += (j-i) ** 2
    ans = min(ans,energy)

print(ans)

Solution (Python):
import numpy as np
_ = int(input())
x = np.array(list(map(int, input().split())))
ave = int(round(np.average(x)))
x -= ave
ans = np.power(x, 2)
ans = np.sum(ans)
print(ans)

Solution (Python):
n = int(input())
xs = list(map(int, input().split(" "))) + list(range(100 - n))

ans = 9999999999999999
for i in range(1, 100):
    ans = min(ans, sum([(xs[j] - i)**2 for j in range(n)]))

print(ans)

Solution (Python):
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))

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

P = sum(X)//N
P2 = P+1
P3 = P-1
def score(X,P):
    s = 0
    for i in range(N):
        s += (X[i]-P)**2
    return s

S0 = score(X,P)
S1 = score(X,P2)
S2 = score(X,P3)

print(min(S0,S1,S2))

Solution (Python):
N = int(input())
x = list(map(int, input().split()))
pos = round(sum(x) / N)
power = 0
for x_i in x:
    power += pow(x_i - pos, 2)
print(power)

Solution (Python):
N = int(input())
l_x = list(map(int, input().split()))
d_min = 999999999999999
left = min(l_x)
right = max(l_x)
for p in range(left, right + 1):
  total = 0
  for x in l_x:
    total += (p - x) ** 2
  if total < d_min:
    d_min = total

print(d_min)

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


if __name__ == '__main__':
    main()

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

Solution (Python):
n=int(input())
x=[i for i in map(int, input().split())]
ans=1000000000000000000000000000000000000000
x.sort()

for i in range(x[n-1]+1):
  cnt=0
  for k in x:
    cnt= cnt+(k-i)**2
  ans=min(ans,cnt)
print(ans)

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

ans = 10000000000
for i in range(min(X), max(X) + 1):
    tmp_ans = 0
    for j in range(N):
        tmp_ans += (X[j] - i) ** 2 
    ans = min(ans, tmp_ans)
print(ans)

Solution (Python):
n = int(input())
x = [int(a) for a in input().split()]
ans = 0
for i in range(0,101):
    res = 0
    for j in x:
        res += (j-i)**2
    if i==0:
        ans = res
    elif ans > res:
        ans = res
print(ans)

Solution (Python):
n = int(input())
x = [int(a) for a in input().split()]
b = list()
for i in range(0,101):
    res = 0
    for j in x:
        res += (j-i)**2
    b.append(res)
print(min(b))

Solution (Python):
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)

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
ans = 10**10
for p in range(min(x), max(x)+1):
    sumation = 0
    for i in x:
        s = (i-p)**2 
        sumation += s
    ans = min(ans, sumation)
print(ans)

Solution (Python):
N = int(input())
X = [int(_) for _ in input().split()]

ans = 10 ** 10
for p in range(min(X), max(X)+1):
    a = sum([(x - p) ** 2 for x in X])
    ans = min(ans, a)
print(ans)

Solution (Python):
import sys

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

p=round(sum(x)/n)

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

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
print(min(sum((X[i] - j) ** 2 for i in range(N)) for j in range(1, 101)))

Solution (Python):
N = int(input())
X = [int(x) for x in input().split(' ')]
P = sum(X) // N
S1 = sum([(x - P)**2 for x in X])
S2 = sum([(x - (P+1))**2 for x in X])
S = min([S1, S2])
print(S)

Solution (Python):
n = int(input())
X= [int(i) for i in input().split()]
X.sort()

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

Solution (Python):
n = int(input())
X= list(map(int,input().split()))
X.sort()

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

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

ans = 1e10

for pos in range(1,101):
  work = 0
  for x in X:
    work += (pos - x) ** 2
  ans = min(ans, work)
  
print(ans)

Solution (Python):
n = int(input())
N = list(map(int,input().split()))
result = 1000001
for i in range(100):
    total = 0
    for j in range(n):
        total += (i - N[j])**2
    if (result>total):
        result = total
print(result)

Solution (Python):
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))

Solution (Python):
n=int(input())
x=list(map(int, input().split()))
p=round(sum(x)/n)
ans=0
for i in x:
    ans+=(i-p)*(i-p)
print(ans)

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
ans=10**10
for i in range(100):
    res=0
    for j in range(n):
        res+=(x[j]-i-1)**2
    
    ans=min(ans,res)
    

print(ans)

Solution (Python):
N = input()
X = list(map(int,input().split()))
result = []
i = 1

while i <= 100:
  sum = 0
  for j in X:
    sum += (j - i) ** 2
  result.append(sum)
  i += 1
  
print(min(result))

Solution (Python):
n = int(input())
X = list(map(int, input().split(' ')))
min_ps = None

for i in range(100):
    ps = sum([(xi - i)**2 for xi in X])
    if min_ps==None:
        min_ps = ps
    elif min_ps > ps:
        min_ps = ps

print(min_ps)

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
sumX = 0
for i in x:
    sumX += (i - round(sum(x)/n)) ** 2
print(sumX)

Solution (Python):
from statistics import mean

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

ave = mean(A_list)
ave_r = round(ave)

dist = 0
for A in A_list:
    dist += (A - ave_r) ** 2
print(dist)

Solution (Python):
n=int(input())

listx = list(map(int,input().split()))
a= 1000100

for i in range(max(listx)):
	p=i+1
	all=0
	for x in listx:
		all += (x-p)**2
	if all < a:
		a = all

print(a)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
mid=sum(a)//n
ret=10000010
x=0
y=0
for i in a:
  x += (i-mid)**2
  y += (i-(mid+1))**2
print(min(x,y))

Solution (Python):
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)

Solution (Python):
def main():
    N = int(input())
    X = list(map(int, input().split(" ")))
    calc = [0]*max(X)
    for i in range(max(X)):
        for j in range(N):
            calc[i] += (X[j] - (i+1))**2

        
    print(min(calc))

if __name__ == '__main__':
    main()

Solution (Python):
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))

Solution (Python):
n = int(input())

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

ans = float('inf')

for i in range(1,101):
  ans_temp = 0
  for j in x:
    ans_temp += (j-i)**2
  ans = min(ans,ans_temp)
print(ans)

Solution (Python):
N=int(input())
X=list(map(int, input().split()))
sum=sum(X)
ave=round(sum/N)
Y=0
for i in X:
	Y+=(i-ave)**2
print(Y)

Solution (Python):
N = int(input())
X = list(map(int, input().split(" ")))

sum_ = 0

m = round(sum(X) / N)

for i in range(0, len(X)):
  sum_ += (X[i] - m) ** 2

print(sum_)

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
min = 1000000

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

print(min)

Solution (Python):
n = int(input())
List = list(map(int, input().split()))

min = 100000000000000000000

for P in range(101):
    X=0
    for num in List:
        X += (P-num)**2
    if min > X:
        min = X

print(min)

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

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

    ans = min(ans, power)

print(ans)

Solution (Python):
N=int(input());A=list(map(int,input().split()))
ans=100000000000000
for x in range(1,101):
  ans=min([sum([(x-a)**2 for a in A]),ans])
print(ans)

Solution (Python):
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

n = int(input())
x_list = list(map(int, input().split()))
a = int(Decimal(str(sum(x_list)/n)).quantize(Decimal('0'), rounding=ROUND_HALF_EVEN))

ans = 0
for x in x_list:
    ans += (x-a)**2
print(ans)

Solution (Python):
n = int(input())
s = list(map(int, input().split()))
sum = 0
for i in range(n):
    sum += s[i]
ave = round(sum / n)

for i in range(n):
    s[i] = s[i] - ave
    s[i] = s[i] * s[i]
ans = 0
for i in range(n):
    ans += s[i]

print(ans)

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
s = min(X)
g = max(X)
ans = 10**9
for i in range(s,g+1):
    d = 0
    for x in X:
        d += (x-i)**2
    ans = min(ans,d)
print(ans)

Solution (Python):
from statistics import median

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

min_sum = 10**9
for location in range(min(p), max(p)+1):
    sum = 0
    for i in range(n):
        sum += (p[i]-location)**2
    if sum < min_sum:
        min_sum = sum

print(min_sum)

Solution (Python):
N = int(input())
Xs = [int(i) for i in input().split()]

base = int(round(sum(Xs) / N))
ans = 0
for x in Xs:
    ans += (x - base) ** 2

print(ans)

Solution (Python):
n = int(input())

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


ans = 10000000
for i in range(1,101):
    y = 0
    for j in x:
        y += (j-i)*(j-i)
    ans = min(ans,y)

print(ans)

Solution (Python):
N = int(input())
man = []
man= list(int(i) for i in input().split())

min_n = float('inf')
for x in range(100):
    sum =0
    for y in man:
        sum +=(x-y)**2
    if sum<min_n:
        min_n =sum
print(min_n)

Solution (Python):
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(0)
else :
    print(minimum)

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
a=sum(x)//n
ans1=0
ans2=0
for i in range(n):
    ans1+=(a-x[i])**2
    ans2+=(a+1-x[i])**2
print(min(ans1,ans2))

Solution (Python):
from statistics import mean
N = int(input())
X = input().split()
for i in range(len(X)):
    X[i] = int(X[i])
goal = round(mean(X)) 
sum = 0
for i in range(len(X)):
    sum += (X[i] - goal) ** 2
print(sum)

Solution (Python):
import sys
import math

ta=int(input())
ans=0
sum=0
li= [int(x) for x in input().split()]
for i in range(ta):
  sum+=li[i]
sum=round(sum/ta)
for i in range(ta):
  ans+=pow((li[i]-sum),2)
print(ans)

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

result = 10000000000
for i in range(100):
    tmp = 0
    for j in range(n):
        tmp += pow((x[j] - i), 2)

    if tmp < result:
        result = tmp
print(result)

Solution (Python):
n = int(input())
x = list(map(int,input().split()))
ans = int(sum(x)**2)
current = 0
for p in range(min(x)-1,max(x)+1):
    for i in range(len(x)):
        current += int((x[i] - p)**2)
    if(current < ans):
        ans = current
    current = 0
print(ans)

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
Min = 1e10
for p in range(1,101):
    Min = min(Min,sum(map(lambda x: (x-p)**2, X)))
print(Min)

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
Min = 1e10
for p in range(1,101):
    Min = min(Min,sum(list(map(lambda x: (x-p)**2, X))))
print(Min)

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

    x_min = min(x_list)
    x_max = max(x_list)
    hp_min = None

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

    print(hp_min)

if __name__ == "__main__":
    resolve()

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
x.sort()
ans=10**18
for p in range(min(x),max(x)+1):
  s=0
  for j in range(n):
    s+=(p-x[j])**2
  ans=min(ans,s)
print(ans)