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):
number = int(input())
score = list(map(int,input().split()))
kiroku = 10**10
for i in range(100):
    answer = 0
    for j in range(number):
        answer += (score[j] - i-1)**2
    if answer < kiroku:
        kiroku = answer
print(kiroku)

Solution (Python):
import numpy as np
n=int(input())
x1=list(map(int,input().split()))
ans=1000000000000000000000
for i in np.arange(1,101):
    hp=0
    for j in x1:
        hp+=(j-i)*(j-i)
    if hp<=ans:
        ans=hp
print(ans)

Solution (Python):
def mapt(fn, *args):
    return tuple(map(fn, *args))

def main():
    n = int(input())
    x = mapt(int, input().split(" "))
    ans = float("inf")
    for p in range(1, 101):
        r = 0
        for xj in x:
            r += (xj-(p))**2
        ans = min(ans, r)
    print(ans)

main()

Solution (Python):
n=int(input())
x = [int(x) for x in input().split()]

heikin=(sum(x)/n)

if abs(int(heikin)-heikin)<abs(int(heikin+1)-heikin):
    kaisai=int(heikin)
else:
    kaisai=int(heikin+1)

ans=0

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

print(ans)

Solution (Python):

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

min_x = X[0]
max_x = X[0]
for i in range(N):
  if X[i] > max_x: max_x = X[i]
  if X[i] < min_x: min_x = X[i]

ans = 10000000
for p in range(min_x, max_x+1):
  ans_p = 0
  for x in X:
    ans_p += (x-p)**2
  if ans > ans_p: ans = ans_p

print(ans)

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

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

Solution (Python):
def nearest_int(f):
  if f - int(f) < 0.5:
    return int(f)
  else:
    return int(f) + 1

N = int(input())
X = list(map(lambda x: int(x), input().split(" ")))
ave = sum(X) / N
avei = nearest_int(ave)

print(sum([(x - avei) ** 2 for x in X]))

Solution (Python):
import math
a = int(input())
answer = 100000000
b = list(map(int,input().split()))
for i in range(1,101):
    cost = 0
    for j in b:
        cost+=(j-i)**2
    answer = min(answer,cost)
print(answer)

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

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

ans = 10**6

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

print(ans)

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

X_g = sum(X)/N

if X_g%1<0.5:
    P = int(X_g)
else:
    P = int(X_g)+1
ans = 0
for i in range(N):
    ans += (X[i]-P)**2

print(ans)

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
ans = 1<<60
for center in range(101):
    a = 0
    for x in X:
        a += (x - center) ** 2
    if a < ans:
        ans = a
print(ans)

Solution (Python):
def resolve():
    N = int(input())
    X = list(map(int, input().split()))
    av = sum(X)/N
    def _round(x, d=0):
        import math
        p = 10 ** d
        return math.floor(x*p)/p if (x*p)%1 < 0.5 else math.ceil(x*p)/p
    P = round(av)
    ans = 0
    for x in X:
        ans += (x-P)**2
    print(ans)

if '__main__' == __name__:
    resolve()

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

ans = []
for p in range(100+1):
    phys = 0
    for x in X:
        phys += (x-p)**2
    ans.append(phys)

print(min(ans))

Solution (Python):
import sys

def main():

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

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

    print(m)


main()

Solution (Python):
n = input()
s = list(map(int,input().split()))
m = 10000000
for p in range(0,101):
  t = 0
  for x in s:
    t+=(x-p)**2
  m = min(t,m)
print(m)

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

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

Solution (Python):
import math
N=int(input())
C=list(map(int,input().split()))
ave = sum(C) / len(C)
X=math.floor(ave)
Y=X+1
Xsum,Ysum=0,0
for i in range(len(C)):
  Xsum += (C[i]-X)**2
  Ysum += (C[i]-Y)**2
print(min([Xsum,Ysum]))

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

Solution (Python):
n=int(input())
l = [int(x) for x in input().split()]
p = int(sum(l)/n + 0.5)
ans = 0
for i in range(n):
    ans += (p-l[i])**2
    
print(ans)

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

total_list = []
for p in range(min(X), max(X) + 1):
    total = 0
    for x in X:
        total += (x - p) ** 2
    total_list.append(total)

print(min(total_list))

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

Solution (Python):
import sys

N = next(sys.stdin.buffer)
X = tuple(map(int, next(sys.stdin.buffer).split()))

min_x = min(X)
max_x = max(X)

stamina = min(sum((p - x) ** 2 for x in X) for p in range(min_x, max_x + 1))

print(stamina)

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
ans = 50 ** 2 * 100
for P in range(1,101):
    sum = 0
    for i in range(N):
        sum += (X[i] - P) ** 2
    if sum < ans:
        ans = sum
print(ans)

Solution (Python):
import math
n = int(input())
x = list(map(int,input().split(" ")))
a=math.ceil(sum(x)/n)
s = sum((xx - a)**2 for xx in x)
tmp = s
a = a-1
s = sum((xx - a)**2 for xx in x)
if s > tmp:
    print(tmp)
else:
    print(s)

Solution (Python):
N=int(input())
X=sorted(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)

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
ans=1000000000000
for p in range(100):
    a=0
    for i in range(n):
        a+=(x[i]-p)**2 
    if a < ans:
        ans = a

print(ans)

Solution (Python):
from numpy import average
from decimal import Decimal, ROUND_HALF_UP
 
n=int(input())
x=list(map(int,input().split()))
 
p=Decimal(str(average(x))).quantize(Decimal('1'),rounding=ROUND_HALF_UP)
 
ans=0
for i in x:
	ans+=((i-p)**2)

print(ans)

Solution (Python):
from numpy import average
from decimal import Decimal, ROUND_HALF_UP

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

p=Decimal(str(average(x))).quantize(Decimal('0'),rounding=ROUND_HALF_UP)

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

print(ans)

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

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

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
loc = round(sum(a) / N)
print(sum(map(lambda x: (x - loc) ** 2,a)))

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
p = round(sum(X)/len(X))
print(sum([(x-p)**2 for x in X]))

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

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

print(min(A))

Solution (Python):
def getDis(X,p):
    res = 0
    for x in X:
        res += (x-p)**2
    return res

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

p = sum(X)//n

for i in range(n):
    d = getDis(X,p)
    if d>getDis(X,p+1):
        p+=1
    elif d>getDis(X,p-1):
        p-=1
    else:
        break

print(d)

Solution (Python):
N = int(input())
X = tuple(map(int, input().split()))
ans = 10 ** 7
for p in range(min(X), max(X) + 1):
    total = 0
    for x in X:
        total += (x - p) ** 2
    ans = min(ans, total)
print(ans)

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
al = []
for i in range(100):
  d = 0
  p = i+1
  for j in range(N):
    d += (X[j]-p)**2
  al.append(d)

print(min(al))

Solution (Python):
def rally(arr):
	p = max(arr)
	summ = 0
	best = float('inf')
	for i in range(1, p+1):
		summ = 0
		for j in arr:
			summ += (j - i) ** 2
		best = min(best, summ)
	return best
n = int(input())
arr = list(map(int, input().split()))
print(rally(arr))

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
ans=10**12
cou=0

for i in range(min(x),max(x)+1):
  for j in range(n):
    cou+=(x[j]-i)**2
  if cou<ans:
    ans=cou
  cou=0  
print(ans)

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

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

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

Solution (Python):
def solve():
    N = int(input())
    X = [int(i) for i in input().split()]
    from decimal import Decimal, ROUND_HALF_UP
    target = int(Decimal(sum(X)/float(N)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
    ans = 0
    for x in X:
        ans += (x-target)**2
    print(ans)

if __name__ == "__main__":
    solve()

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
a = sorted(a)
k = 10**6

for i in range(a[0],a[-1]+1):
  total = 0
  for s in a:
    total +=(i-s)**2
  
  k = min(k,total)
print(k)

Solution (Python):
n = int(input())
x_list = list(map(int, input().split()))
m = int(sum(x_list)/n + 0.5)
print(sum((x - m)**2 for x in x_list))

Solution (Python):
N = int(input())
X = [int(x) for x in list(input().split())]
max_x = max(X)
min_x = min(X)
d = max_x - min_x
middle = (d//2)
P = middle + min_x
ans = 0
for i in range(N):
  ans += (max_x-X[i])**2
for i in range(d):
  n_ans = 0
  P = min_x + i
  for j in range(N):
    n_ans += (P-X[j])**2
  if (n_ans < ans):
    ans = n_ans
print(int(ans))

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

Solution (Python):

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

P_list = []
for P in range(1, max(X)+1):
    P_list.append(P)

HP_min =10**8
for i in range(len(P_list)):
    HP = 0
    for j in range(N):
        HP += (X[j] - P_list[i])**2
    
    if HP < HP_min:
        HP_min = HP
print(HP_min)

Solution (Python):
import sys

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

if len(list(set(x))) == 1:
    print(0)
    sys.exit()

if n == 1:
    print(0)
    sys.exit()

x_min = x[0]
x_max = x[n-1]
min_sum = 10000000
for p in range(x_min, x_max):

    sum = 0
    for e in x:
        len = (e - p)**2
        sum += len
    
    if sum <= min_sum:
        min_sum = sum
print(min_sum)

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
val1 = sum(A)//n
val2 = val1+1
ans1 = 0
ans2 = 0
for a in A:
    ans1 += (a-val1)**2
    ans2 += (a-val2)**2
print(min(ans1,ans2))

Solution (Python):

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

    ans = INF
    for p in range(0, 102):
        t = 0
        for x in X:
            t += (x - p) ** 2
        ans = min(ans, t)
    print(ans)

def main():
    solve()


if __name__ == '__main__':
    main()

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

ans = 1000000000

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

print(ans)

Solution (Python):
def main():
    n = int(input())
    X = [int(x) for x in input().split()]
    ave_x = int(sum(X) / len(X))
    error_1 = 0
    error_2 = 0
    for x in X:
        error_1 += (x-ave_x) ** 2
        error_2 += (x-(ave_x+1)) ** 2
        min_e = min(error_1, error_2)
    print(min_e)
    
if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n = int(input())
    X = [int(x) for x in input().split()]
    min_x = min(X)
    max_x = max(X)
    min_e = 10**6
    for i in range(min_x, max_x+1):
        error = 0
        for x in X:
            error += (x-i) ** 2
        min_e = min(min_e, error)
    print(min_e)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
hp_min = 10000 * n
for i in range(1, 101):
    hp = sum([(x[j] - i) ** 2 for j in range(len(x))])
    if hp < hp_min:
        hp_min = hp
print(hp_min)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
p=round(sum(A)/N)
print(sum(map(lambda x: (x-p)**2, A)))

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

HP = []
for p in range(1, 101, 1):
    P = [p] * len(X)
    delta = sum([(i - j) ** 2 for (i, j) in zip(X, P)])
    HP.append(delta)

print(min(HP))

Solution (Python):
def dist(x, p):
    return (x - p)**2


n = int(input())
x = [int(i) for i in input().split()]
index = len(x) // 2
new_x = sorted(x)
p1 = - (- sum(x) // len(x))
p2 = sum(x) // len(x)
ans = [0, 0]
for i in new_x:
    ans[0] += dist(i, p1)
    ans[1] += dist(i, p2)
print(min(ans))

Solution (Python):
input()
*X,=sorted(map(int,input().split()))
print(min(sum((n-p)**2 for n in X) for p in range(X[0], X[-1]+1)))

Solution (Python):
N=int(input())
*X,=sorted(map(int,input().split()))
a=10**9
for p in range(X[0], X[-1]+1):
 a=min(a, sum((n-p)**2 for n in X))
print(a)

Solution (Python):
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools

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

if __name__=="__main__":
    main()

Solution (Python):
input()
l = list(map(int,input().split()))
l.sort()
ans = 1000000
n_ans = 0
for i in range(l[0],l[len(l)-1]+1):
  for j in range(len(l)):
    n_ans += (l[j]-i) ** 2
  if n_ans <= ans:
    ans = n_ans
    n_ans = 0
  else:
    n_ans = 0
print(ans)

Solution (Python):
n=int(input())
x=list(map(int, input().strip().split()))
X=0
for i in range(n):
    X+=x[i]
XX=0
for i in range(n):
    XX+=(x[i])**2
s=X//n
t=s+1
S=n*(s**2)-2*s*X+XX
T=n*(t**2)-2*t*X+XX
print(min(S,T))

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

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

Solution (Python):
from decimal import Decimal, ROUND_HALF_UP

n = int(input())
x = list(map(int,input().split()))
a = Decimal(sum(x) / n).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
ans = 0

for i in range(n):
    ans += (x[i] - a) ** 2

print(ans)

Solution (Python):
n = int(input())
X = sorted(list(map(int,input().split())))
ans = 10**10

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

print(ans)

Solution (Python):





N = int(input())









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

tots = []
for i in range(1, 101):
    tot = 0
    for j in X:
        tot += (j - i) ** 2
    tots.append(tot)

print(min(tots))

Solution (Python):

def inputlist(): return [int(j) for j in input().split()]
def listinput(): return input().split()

N = int(input())
X = inputlist()
ans = 10**9+7
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(map(int, input().split()))
count = 0
ave = round(sum(X) / len(X))

for i in X:
  count += (i - ave)**2

print(count)

Solution (Python):

N = int(input())
X = list(map(int, input().split()))
ans = 10e9
for i in range(0,max(X)+1):
    tmp = 0
    for j in range(N):
        tmp += (X[j]-i)**2
    if tmp < ans:
        ans = tmp

print(ans)

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

X_mean = round(sum(X_list) / N)

physical_sum = sum([(i - X_mean)**2 for i in X_list])
print(physical_sum)

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
x = sorted(inpl())

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

print(ans)

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

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

    for j in range(n):
        y+=(x[j]-i)**2
    ans.append(y)
print(min(ans))

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

P = round(sum(numbers)/N)

sum = 0
for i in range(N):
  sum += (numbers[i] - P)**2

print(sum)

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

X=[0]
for i in array:
    X.append(i)

INF=10000000

dp=[[INF for j in range(100+1)] for j in range(N+1)]

for i in range(100+1):
    dp[0][i]=0

for i in range(1,N+1):
    for j in range(1,100+1):
        dp[i][j]=min(dp[i][j],dp[i-1][j]+(X[i]-j)**2)
        
ans=INF
for i in range(1,100+1):
    ans=min(ans,dp[N][i])

print(ans)

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

Solution (Python):
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
X = inintl()

p = 0
min_d = 10**10
ans = 0

for i in range(1,max(X)+1):
    t_d = 0
    for x in X:
        t_d += (x-i)**2
    if t_d < min_d:
        min_d = t_d
        p = i

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

print(ans)

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

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
print(sum([(xi - round(sum(x)/n))**2 for xi in x]))

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
print(sum([(xi - round(sum(x)/n))**2 for xi in x]))

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


pdlist=[]

for i in range(101):
    pd=0
    for j in X:
        pd+=(i-j)**2
    pdlist.append(pd)
    
pdlist.sort()
print(pdlist[0])

Solution (Python):
n=int(input())
man=list(map(int,input().split()))
can=[]
for i in range(1,101):
	pp=0
	for j in range(len(man)):
		bp=(man[j]-i)**2
		pp+=bp
	can.append(pp)
can.sort(key=int)
print(can[0])

Solution (Python):
a=int(input())
b=list(map(int,input().split()))
bmax=max(b)+1
bmin=min(b)
ans=1000000
for i in range(bmin,bmax,1):
  e=0
  for j in b:
    e+=(i-j)**2
  ans=min(ans,e)
print(ans)

Solution (Python):
import math

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



xmin = 10 ** 7

for i in range(1, 101):
    xsum = 0
    for j in range(N):
        xsum += (X[j] - i) ** 2
    xmin = min(xmin, xsum)

print(xmin)

Solution (Python):
N=int(input())
List = list(map(int, input().split()))
res = 1000000000000
mid = 0
for i in range(101):
  for j in range(N):
    mid += (i-List[j])**2
  res = min(res,mid)
  mid = 0
print(res)

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

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
min_sum = 10**9
for i in range(min(l),max(l)+1):
    min_sum = min(min_sum,sum([(j-i)**2 for j in l]))

print(min_sum)

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

ans = 10**10
for P in range(0, 102):
    cost = 0
    for X in Xs:
        cost += (X-P)**2
    ans = min(ans, cost)

print(ans)

Solution (Python):










INF = pow(10,6)


def solve(n,a):
  res = INF
  for i in range(1,101):
    res = min(res,sum(pow(i-x,2) for x in a))
  return res



def main():
  N = int(input())
  
  a = list(map(int,input().split()))
  print(solve(N,a))
  return

if __name__ == '__main__':
  main()

Solution (Python):
N = int(input())
x = []
hp = []
xa = 0
hpsum = 0

x = [int(e) for e in input().split()]
for i in range(N):
    xa += x[i]



xa = xa / N

if xa % 1 < 0.5:
    xa = int(xa / 1)
elif xa % 1 >= 0.5:
    xa = int(xa / 1 + 1)

for j in range(N):
    hp.append((x[j]-xa)*(x[j]-xa))
    hpsum += hp[j]

print(int(hpsum))

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

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

minimum = 10000000

for n in range(1,max(X)+1):
  kyori = 0
  for i in range(N):
    kyori += (X[i]-n)**2
  if kyori < minimum:
    minimum = kyori
print(minimum)

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

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

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

Solution (Python):


from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


def solve(N: int, X: "List[int]"):
    return min([sum([(x-i)**2 for x in X]) for i in range(1, 100+1)])


def main():

    sys.setrecursionlimit(10 ** 6)

    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)]  
    print(f'{solve(N, X)}')


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
average = round(sum(X) / len(X))
health = 0
for x in X:
    health += (average - x)** 2
print(health)

Solution (Python):
import numpy as np

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

X = np.sort(X)
minX = X[0]
maxX = X[-1]
ans = 999999999

for i in range(minX, maxX+1, 1):
    x = (X - i) ** 2
    total = np.sum(x)
    ans = min(ans, total)

print(ans)

Solution (Python):
N,*X = map(int, open(0).read().split())
ans = float('inf')
for i in range(1,max(X)+1):
    temp = 0
    for j in range(N):
        temp += (X[j]-i) ** 2
    ans = min(ans,temp)
print(ans)

Solution (Python):















































global FLAG_LOG
FLAG_LOG = False


def log(value):
    
    
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    
    N = int(lines[0])
    
    values = list(map(int, lines[1].split()))
    
    
    
    
    
    
    

    result = None
    for p in range(101):
        su = 0
        for n in range(N):
            su += (values[n] - p)**2
        if result is None:
            result = su
        elif result > su:
            result = su

    return [result]



def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2', '1 4']
        lines_export = [5]
    if pattern == 2:
        lines_input = ['7', '14 14 2 13 56 2 37']
        lines_export = [2354]
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

Solution (Python):
def Rally():
    
    N = int(input())
    X = list(map(int, input().split()))
    
    max_num = max(X)
    min_num = min(X)
    
    min_sum = list()
    for P in range(min_num, max_num+1):
        sum = 0
        for i in range(N):
            sum += (X[i] - P)**2
        min_sum.append(sum)
    
    return min(min_sum)

result = Rally()
print(result)

Solution (Python):
n, x = int(input()), list(map(int, input().split()))
px = 0
a = 100 ** 100
for i in range(100):
  s = 0
  for j in x:
    s += (i-j) ** 2
  if a > s:
    a = s
print(a)

Solution (Python):
n = int(input())
xn = [int(num) for num in input().split()]

answer = []
for n in range(1,max(xn)+1):
  sum = 0
  for x in xn:
    sum += (x-n)**2
  answer.append(sum)

print(min(answer))

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

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

p = int(round(numpy.average(x)))

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

print(ans)

Solution (Python):
from sys import stdin
import sys
import math
from functools import reduce
import itertools

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

p = int(sum(x)/n)
q = p+1

a = sum([(i-p)**2 for i in x])
b = sum([(i-q)**2 for i in x])

print(min([a,b]))

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

Solution (Python):
import sys


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    x = list(map(int, input().split()))
    ans = 10 ** 10
    for p in range(1, 101):
        s = 0
        for home in x:
            s += (home - p) ** 2
        ans = min(ans, s)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np
from math import ceil, floor
 
n = int(input())
l = [int(x) for x in input().split()]
 
c = ceil(np.array(l).mean())
f = floor(np.array(l).mean())

print(min(sum([(x-c)**2 for x in l]), sum([(x-f)**2 for x in l])))

Solution (Python):
import math


def resolve():
    import sys
    input = sys.stdin.readline
    row1 = [int(x) for x in input().rstrip().split(" ")]
    row2 = [int(x) for x in input().rstrip().split(" ")]

    n = row1[0]
    minx = min(row2)
    maxx = max(row2)

    min_sum = float('inf')
    index = -1
    for i in range(minx,maxx+1):
        tmp = sum([(x-i)**2 for x in row2])
        if tmp < min_sum:
            min_sum = tmp
    print(min_sum)







if __name__ == "__main__":
    resolve()

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
result=0
if sum(x)%n==0:
  for i in range(n):
    result+=(x[i]-sum(x)//n)**2
elif sum(x)%n<=n/2:
  for i in range(n):
    result+=(x[i]-sum(x)//n)**2
else:
  for i in range(n):
    result+=(x[i]-sum(x)//n-1)**2
  
print(result)

Solution (Python):
N = int(input())
X1 = list(map(int, input().split()))
ans = []
if N == 1:
    print(0)
    exit()
    
if min(X1) == max(X1):
    print(0)
    exit()
    
for p in range(min(X1), max(X1)):
    num = 0
    for i in range(N):
        num += (X1[i] - p)*(X1[i] - p)
        
    ans.append(int(num))

print(min(ans))

Solution (Python):
n = int(input())
X = list(map(int, input().split()))
for pos in range(1, 101):
    tmp = 0
    for x in X:
        tmp += pow((x - pos), 2)
    if pos == 1:
        ans = tmp
    else:
        ans = min(tmp, ans)
print(ans)

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

ave = sum(X) / N
ans1 = int(ave)
ans2 = int(ave) + 1

count1 = 0
count2 = 0
for i in range(N):
    count1 += abs(X[i] - ans1) ** 2
    count2 += abs(X[i] - ans2) ** 2
    
print(min(count1, count2))

Solution (Python):
n = int(input())
list_ = list(map(int,input().split()))
min_ = min(list_)
max_ = max(list_)
num=[]
for a in range(min_,max_):
  _ = []
  for b in range(len(list_)):
    _.append((a - list_[b])**2)
  num.append(sum(_))
if len(list(set(list_))) == 1:
  print(0)
  exit()
print(min(num))