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()))

ave = sum(X) // len(X)

ans1 = 0
ans2 = 0
for x in X:
        ans1 += (ave+1-x)**2
        ans2 += (ave-x)**2

print(min(ans1,ans2))

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

ans = 0
mx = 10**100
for i in range(1,101):
    mm = 0
    for j in range(N):
        mm += (i-X[j])**2

    mx = min(mx,mm)
print(mx)

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

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
X = [int(x) for x in input().split()]
X.sort()
ans = 10 ** 10

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

print(ans)

Solution (Python):
import heapq
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(n):
  res = 0
  for x in a:
    res += (n-x)**2
  return res

N = I()
a = IL()

ans = MAX_INT
for i in range(1,101):
  ans = min(ans, tami(i))
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)

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

cnt = 10 ** 10
for i in range(101):
    p = 0
    for x in X:
        p += (i - x) ** 2

    cnt = min(cnt, p)

print(cnt)

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

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
l=min(x)
r=max(x)
ans=10**9
for p in range(l,r+1):
  d=0
  for i in range(n):
    d+=(p-x[i])**2
  ans=min(ans,d)
print(ans)

Solution (Python):
import numpy as np
N = int(input())
X = np.array(list(map(int,input().split())))


ans = 10**10
for i in range(1,101):
    ans = min(ans, np.sum((X-i)**2))
print(ans)

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 main():
    N = I()
    X = LI()
    ans = inf
    for x in range(1, 101):
        cur_ans = 0
        for point in X:
            cur_ans += (x - point) ** 2
        ans = min(cur_ans, ans)
    print(ans)

main()

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

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

ans = 10**9

for i in range(min(X), max(X)+1):
  temp = 0
  for x in X:
    temp += (i-x)**2
  ans = min(ans, temp)
  
print(ans)

Solution (Python):


from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n = ii()
    x = li()
    amin = 100000000000
    
    for i in range(101):
        tmp = 0
        for j in x:
            tmp+=(i-j)**2
        amin = min(amin,tmp)
    print(amin)



main()

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n = onem()

a = l()

aa = sum(a)/n
po = 0
aaa = sum(a)//n
if aa != sum(a)//n:
    ppo = 0
    for i in range(n):
        po += (aaa - a[i])**2
    aaa += 1
    for i in range(n):
        ppo += (aaa - a[i])**2
    po = min(po,ppo)

else:
    for i in range(n):
        po += (aaa - a[i])**2

print(po)

Solution (Python):
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

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

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
INF = 10 ** 9

ans = INF
for p in range(1, 101):
    d = 0
    for xi in x:
        d += (xi - p) ** 2
    ans = min(ans, d)

print(ans)

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

ans = 100000000000000

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

    ans = min(a, ans)


print(ans)

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

Solution (Python):
import numpy as np 
n = int(input())
x = list(map(int, input().split()))
x = np.array(x)
ans = float('inf')
idx = 200
for i in range(100):
  y = x 
  ans = min(ans, np.sum((y-i)**2))
  
print(ans)

Solution (Python):
def main():
    N = int(input())
    X = list(map(int, input().split()))
    X.sort()
    ans = float('inf')
    for i in range(1, max(X)+1):
        d = 0
        for j in range(N):
            d += pow((i - X[j]), 2)
        ans = min(ans, d)
    return ans


if __name__ == '__main__':
    print(main())

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


if __name__ == '__main__':
    resolve()

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

x = np.array(x)

d = x - int(np.mean(x))
a = np.sum(d ** 2)

d = x - int(np.mean(x)) - 1
b = np.sum(d ** 2)


print(min(a, b))

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

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

ans = []
for p in range(101):
    val = 0
    for i in range(n):
        val +=(x[i] - p)**2
    ans.append(val)
print(min(ans))

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

Solution (Python):
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) 
def lcm(a,b):return (a*b) // fractions.gcd(a,b) 
def iin(): return int(input()) 
def ifn(): return float(input()) 
def isn(): return input().split() 
def imn(): return map(int, input().split()) 
def fmn(): return map(float, input().split()) 
def iln(): return list(map(int, input().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, input().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
def m_add(a,b): return (a+b) % MOD

N = iin()
X = iln()
ans = 10**10
for i in range(1, 101):
    t = 0
    for j in range(N):
        t += (i-X[j])**2
    ans = min(ans, t)
print(ans)

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

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

Solution (Python):
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n = ni()
x = na()

ans = inf
for i in range(100):
    l = 0
    for j in range(n):
        l += (x[j] - i) ** 2
    ans = min(ans, l)

print(ans)

Solution (Python):
N=int(input())
X=list(map(int,input().split()))
m=10**100
for i in range(0,100):
    test=sum((X[j]-i)**2 for j in range(0,N))
    if test<m:
        m=test
print(m)

Solution (Python):
N=int(input())
x=list(map(int,input().split()))
mi = 10**9
for mid in range(0,max(x)+1):
    tmp = 0
    for val in x:
        tmp += (val-mid)**2
    mi = min([mi,tmp])
print(mi)

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

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

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

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

ans = 10**9
for i in range(min(X), max(X)+1):
    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()))


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

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
ans = 10**15
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 = [int(i) for i in input().split()]
sum = 10**10
for p in range(101):
    ans = 0
    for i in range(N):
        d = (X[i] - p)**2
        ans += d
    sum = min(sum,ans)
print(sum)

Solution (Python):

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)

def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max,mod=DIV):
    fac,finv,inv = [0]*max, [0]*max, [0]*max
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod -inv[mod%i] * (mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
    class CONV:
        def __init__(self):
            pass
        def ncr(self,n,k):
            if(n<k):
                return 0
            if(n<0 or k<0 ):
                return 0
            return fac[n]*(finv[k]*finv[n-k]%mod)%mod
    return CONV()


def main():
    N = iRaw()
    Xs = isRaw()
    nowCost = INF
    nowC = -1
    for c in range(1,101):
        cost =sum([(x-c)**2 for x in Xs])
        if nowCost > cost:
            nowCost = cost
            nowC = c

    return nowCost
    


if __name__ == "__main__":
    print(main())

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

print(ans)

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
ans = float('inf')
for p in range(1, 101):
    tmp = 0
    for x in X:
        tmp += (x-p)**2
    ans = min(ans, tmp)
print(ans)

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

Solution (Python):
import sys
input = sys.stdin.readline
n=int(input())
x=list(map(int,input().split()))
mn=min(x)
mx=max(x)
ans=float("inf")
for i in range(mn,mx+1):
    a=0
    for X in x:
        a+=(i-X)**2
    ans=min(ans,a)
print(ans)

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

A=sum([i*i for i in X])
B=sum(X)
ans=10**15
for P in range(101):
    tmp=A-2*B*P+N*P*P
    ans=min(ans,tmp)
print(ans)

Solution (Python):
N=int(input())
X=list(map(int,input().split()))
a=10000000
for i in range(1,101):
    t=0
    for j in X:
        t+=(j-i)**2
    a=min(a,t)
print(a)

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

o = []
for Y in range(1,101):
    o.append(sum(map(lambda x: (x - Y)**2,X)))

print(min(o))

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

ans = 1000000

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

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

Solution (Python):

"""
Created on Fri Jan 24 14:37:00 2020

@author: matsui
"""

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

cost=[]

for i in range(1,101):
    c=0
    for x in X:
        c+=(x-i)**2
    cost.append(c)

print(min(cost))

Solution (Python):
import sys
readline = sys.stdin.readline
N = int(readline())
X = list(map(int, readline().split()))
X.sort()

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

Solution (Python):
import sys
from operator import itemgetter
from collections import deque, Counter
from itertools import permutations, combinations
from heapq import heapify, heappop, heappush
from bisect import bisect, bisect_left

def solve():
    input = sys.stdin.readline
    N = map(int, input().split())
    X = [int(x) for x in input().split()]
    minx, maxx = min(X), max(X)
    minPow = 1000000000000
    for i in range(minx, maxx+1):
        pow = 0
        for j, x in enumerate(X): pow += (x - i) ** 2
        minPow = min(minPow, pow)
    print(minPow)

    return 0

if __name__ == "__main__":
    solve()

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


ans = 10 ** 10

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

print(ans)

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

ans = 10 ** 10
for i in range(1,101):
    P = i
    cost = 0
    for j in range(N):
        cost += (X[j] - P) ** 2
    ans = min(ans,cost)
print(ans)

Solution (Python):
def main():
    N = int( input())
    X = list( map( int, input().split()))
    now = 10000000
    for i in range(1,101):
        t = 0
        for x in X:
            t += (x-i)**2
        if t < now:
            now = t
    print(now)
if __name__ == '__main__':
    main()

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

ans=1145141919810
for x in range(1,101):
  kyori=0
  for i in range(n):
    kyori+=(A[i]-x)**2
  ans=min(ans,kyori)
  
print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
p = sum(a)//n
P = sum(a)//n + 1
b = [ (x - p)**2 for x in a]
c = [ (x - P)**2 for x in a]
print(min(sum(b),sum(c)))

Solution (Python):

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


INF = 1<<30
ans = INF

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

Solution (Python):


import sys
sys.setrecursionlimit(300000)


def solve(N: int, X: "List[int]"):
    ret = float('inf')
    for p in range(101):
        tmp = 0
        for u in X:
            tmp += (u - p) ** 2
        ret = min(ret, tmp)
    print(ret)
    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())
x = list(map(int, input().split()))
y = sum(x)//n

ans = float("inf")
for i in range(-1,2):
    z = y+i
    tmp = 0
    for j in x:
        tmp += (z-j)**2
    ans = min(ans, tmp)
print(ans)

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

ans=1001001001001

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

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    X = [int(x) for x in input().split()]

    ans = float("inf")
    for a in range(1, 101):
        tmp = 0
        for x in X:
            tmp += (x - a) ** 2
        ans = min(ans, tmp)

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):

N = int(input())

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

ans = float("inf")

for p in range(min(X) - 1 , max(X) + 2):

    now = 0

    for i in X:
        now += (i-p)**2

    ans = min(ans,now)

print (ans)

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

mn = float("inf")

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

    mn = min(mn, sm)

print(mn)

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
h = sum(X)//N
ans = 0
for x in X:
    ans+=(x-h)**2
ans2 = 0
h+=1
for x in X:
    ans2+=(x-h)**2
print(min(ans, ans2))

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

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

ans = float("inf")
for i in range(1, 101):
    tmp = 0
    for idx, x in enumerate(xl):
        tmp += (x - i) ** 2
    ans = min(ans, tmp)
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
INF = 10 ** 20

def main():
    n = getN()
    nums = getList()
    mid = sum(nums) // n
    ans1 = 0
    for num in nums:
        ans1 += (num - mid) ** 2

    

    ans2 = 0
    mid += 1
    for num in nums:
        ans2 += (num - mid) ** 2

    
    mid -= 2
    ans3 = 0
    for num in nums:
        ans3 += (num - mid) ** 2

    print(min(ans1, ans2, ans3))

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
Xs = list(map(int, input().split()))
ans = float('inf')
for p in range(101):
    tmp = 0
    for x in Xs:
        tmp += (p - x)**2
    ans = ans if ans < tmp else tmp
print(ans)

Solution (Python):
from sys import stdin
import math
def input():
	return stdin.readline()[:-1]

def intput():
	return int(input().rstrip())

def sinput():
	return input().rstrip().split()

def intsput():
	return map(int, sinput())

def main():
	n = intput()
	ls = list(intsput())
	min_score = 10**30
	for i in range(1, 101):
		score = 0
		for j in ls:
			score += (j-i)**2
		if score < min_score:
			min_score = score
	print(min_score)



if __name__ == '__main__':
	main()

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

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

point = round(sum(x_list)/len(x_list))

count = 0

for x in x_list:
    count += (x-point)**2

print(count)

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

ans = 999999999
for k in range(100):
    buf = 0
    for i in x:
        buf += (k - i) ** 2
    ans = min(buf, ans)

print(ans)

Solution (Python):
n = int(input())
X = list(map(int, input().split()))
ans = float("inf")
for i in range(1, 101):
  temp = 0
  for x in X:
    temp += (i-x)**2
  ans = min(ans, temp)
print(ans)

Solution (Python):
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



N = int(sys.stdin.buffer.readline())
X = list(map(int, sys.stdin.buffer.readline().split()))

X = np.array(X, dtype=int)


def calc(p):
    return ((X - p) ** 2).sum()


ans = INF
for i in range(200):
    ans = min(ans, calc(i))
print(ans)

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

for i in range(101):
    T=0
    for j in X:
        T+=(j-i)**2
    if T<ans:
        ans=T

print(ans)

Solution (Python):

import sys


def solve(N: int, X: "List[int]"):
    answer = 10**9
    for i in range(101):
        tmp = 0
        for j in range(N):
            tmp += (X[j]-i)**2
        answer = min(tmp,answer)
    print(answer)

    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())
x = list(map(int,input().split()))
al = []
for i in range(1,max(x)+1):
    count = 0
    for j in range(n):
        count += (x[j]-i)**2
    al.append(count)
print(min(al))

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

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]


def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)


n, = get_nums_l()
xxx = get_nums_l()

ans = 9999999999999999999999999
for p in range(1,101):
    a = sum([ (p-x)**2 for x in xxx ])
    ans = min(ans, a)

print(ans)

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

ans = 10**9

for p in range(1,101):
    tmp = 0
    for a in x:
        tmp += (a-p)**2
    ans = min(tmp,ans)

print(ans)

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    x=LIST()
    ct=99999999999
    nmax=max(x)
    nmin=min(x)
    for i in range(nmin,nmax+1):
        temp=0
        for j in x:
            temp+=(j-i)**2
        ct=min(ct,temp)
    print(ct)
if __name__ == '__main__':
    do()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ans=10**9
for i in range(min(a),max(a)+1):
    cnt=0
    for j in a:
        cnt+=(i-j)**2
    ans=min(ans,cnt)
print(ans)

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Solution (Python):
n = int(input())
x = [ int(i) for i in input().split() ]
s = sum(x)
avg = s//n
avg2 = avg+1

ans1 = 0
ans2 = 0
for i in x:
	ans1 += (avg-i)**2
	ans2 += (avg2-i)**2

print(min(ans1,ans2))

Solution (Python):
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]





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

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

Solution (Python):
n = input()
pos = map(int, raw_input().split())
ans = 10**9
for i in range(1, 101):
	tmp = 0
	for j in pos:
		tmp += (i - j)**2
	ans = min(ans, tmp)
print ans

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

ans = 10**9

for P in range(1, 100):
    tmp = 0
    for x in X:
        tmp += (x-P)**2

    ans = min(ans, tmp)
print(ans)

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

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
ans = 10**18
m = min(X)
M = max(X)

for i in range(m, M+1):
    ans_cand = 0
    
    for Xi in X:
        ans_cand += (i-Xi)**2
    
    ans = min(ans, ans_cand)

print(ans)

Solution (Python):
N, *X = map(int, open(0).read().split())
ans = 100000000
for i in range(101):
    d = sum((x-i)**2 for x in X)
    ans = min(ans, d)
print(ans)

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

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

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

for i in range(1,101):
    ans = min(ans,sum([(j-i)**2 for j in x]))
        
print(ans)

Solution (Python):
import sys
inf = sys.maxsize
n = int(input())
x = [int(i) for i in input().split()]

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

Solution (Python):
def main():
    n = int(input())
    *xs, = map(int, input().split())

    ret = float('inf')
    for p in range(100 + 1):
        t = 0
        for x in xs:
            t += (p - x) ** 2
        ret = min(ret, t)
    print(ret)


if __name__ == '__main__':
    main()

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

res = float("inf")
for p in range(110):
    s = 0
    for x in X:
        s += pow(p - x, 2)
    res = min(res, s)

print(res)

Solution (Python):
N = int(input())
X = [int(c) for c in input().split()]
ans = float('inf')
for c in range(102):
  m = 0
  for i in range(N):
    m += (X[i]-c)**2
  ans = min(ans,m)
print(ans)

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

print(ans)

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

Solution (Python):
import sys
input = sys.stdin.readline

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

ans = 10**14
for t in range(101):
    s = 0
    for a in A:
        s += (a-t)**2
    ans = min(ans, s)
print(ans)

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

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



min_cost = 1e18
for i in range(1,101):
    temp_cost = 0
    for j in range(n):
        temp_cost += (arr[j]-i)**2

    if temp_cost < min_cost:
        min_cost = temp_cost

print(min_cost)

Solution (Python):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
X=list(map(int,input().split()))
for p in range(1,100):
  tmp = 0
  for xi in X:
    tmp += (xi-p)**2
  mans = min(mans,tmp)
print(mans)

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
res = float("inf")
for x in range(1, 101):
  t = 0
  for y in a: t += (y - x) ** 2
  res = min(res, t)
print(res)

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

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

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

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

    print(min([sum([(i-p)**2 for i in x]) for p in range(101)]))


main()