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()))
res = 10 ** 15
for i in range(1, 101):
    tres = 0
    for x in X:
        tres += (x - i) ** 2
    res = min(res, tres)
print(res)

Solution (Python):



import sys
readline = sys.stdin.readline
read = sys.stdin.read





n,*x = [int(i) for i in read().split()]


ans = 10**18

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

print(ans)

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

ans = 10 ** 18
for p in range(-100, 200):
    cost = sum((x - p) ** 2 for x in X)
    ans = min(ans, cost)
print(ans)

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):
N=int(input())
X=list(map(int, input().split()))

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
X = LIST()

ans = INF
for i in range(1, 101):
	spot = i
	tmp = 0
	for j in range(N):
		tmp += (X[j]-spot)**2
	if tmp < ans:
		ans = tmp
print(ans)

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

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

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

ans = 1e9
for y in range(110):
    tmp = 0
    for x in X:
        tmp += (y-x)**2
    ans = min(ans,tmp)
print(ans)

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
ans = 10**18
for i in range(101):
    hp = 0
    for j in range(N):
        hp += (X[j]-i)**2
    ans = min(ans,hp)
print(ans)

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

Solution (Python):
import sys

stdin = sys.stdin

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

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

Solution (Python):
def examA():
    N, R = LI()
    ans = R+100*max(0,(10-N))
    print(ans)
    return

def examB():
    N, K = LI()
    ans = 1
    while(N>=K):
        N //=K
        ans += 1
    print(ans)
    return

def examC():
    N = I()
    X = LI()
    ans = inf
    for i in range(101):
        cur = 0
        for x in X:
            cur += (i-x)**2
        ans = min(ans,cur)
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy


from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
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)]) 

def main():
    n = inp()
    x = inpl()
    ans = float('inf')
    for i in range(1,101):
        cnt = 0
        for j in range(n):
            cnt += (i-x[j])**2
        ans = min(ans,cnt)
    print(ans)
    
if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
X = [int(x) for x in input().split()]
ans = 10 ** 9 + 7
for i in range(1,101,1):
    p = 0
    for j in X :
        p += (i - j)**2
    if ans > p :
        ans = p
print(ans)

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
import statistics as st
m=round(st.mean(l))
print(sum((m-i)**2 for i in l))

Solution (Python):

import sys
INF = float("inf")


def solve(N: int, X: "List[int]"):

    m = INF
    for i in range(1, 101):
        tot = 0
        for j in range(N):
            tot += (X[j]-i)**2
        m = min(tot, m)
    print(m)

    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 sys
input = sys.stdin.readline

n = int(input())

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

t = round(sum(A) / n)
ans = 0
for i in range(n):
    ans += (A[i]-t) ** 2
print(ans)

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    X=LI()
    ans = inf
    for a in range(100+1):
        res = 0
        for x in X:
            res += (x-a)**2
        ans = min(ans, res)
    print(ans)
if __name__ == '__main__':
    main()

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

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    X = LI()
    ans = float("inf")
    for x in range(101):
        m = 0
        for xi in X:
            m += (xi-x)**2
        if m < ans:
            ans = m
    print(ans)
    return


if __name__ == "__main__":
    solve()

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

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

Solution (Python):

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
X = read_ints()


def ret_cost(X, P):
    return sum([(x - P) ** 2 for x in X])


ans = 10**10
for P in range(101):
    ans = min(ret_cost(X, P), ans)
print(ans)

Solution (Python):
n = int(input())
xxx = list(map(int, input().split()))
ans = 10**10
for p in range(1, 101):
    tmp = sum((x - p) ** 2 for x in xxx)
    ans = min(ans, tmp)
print(ans)

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

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

ans = 10**9
for i in range(101):
    ans = min(ans, sum([ (i - pi)**2 for pi in person]))
print(ans)

Solution (Python):
import sys

stdin = sys.stdin

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

n = ni()
x = na()

minc = 99999999999999999
for u in range(1, 101):
    cost = 0
    for v in x:
        cost += (v-u)*(v-u)
    minc = min(cost, minc)
print(minc)

Solution (Python):
def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))


N = I()
X = LMI()

p = sum(X) // N
ans1 = sum([(x - p) ** 2 for x in X])
ans2 = sum([(x - p - 1) ** 2 for x in X])
print(min(ans1, ans2))

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

ans=10**10

for i in range(100):
    p=i+1
    temp=0
    for j in range(N):
        temp+=(X[j]-p)**2
        
    ans=min(ans,temp)
    
print(ans)

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

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

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

y = sum(X)//N
c1 = 0
c2 = 0
for x in X:
    c1 += (x-y)**2
    c2 += (x-y-1)**2
print(min(c1, c2))

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

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

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

print(ans)

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

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

Solution (Python):
from collections import *
from itertools import *
from bisect import *
import copy

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

value=10**18
for i in range(0,101):
    value=min(value,sum([(x-i)**2 for x in X]))

print(value)

Solution (Python):
n = int(input())
ans = 10 ** 9
lis = list(map(int,input().split()))
for i in range(0,101):
  num = 0
  for nu in lis:
    num += (nu-i) ** 2
  ans = min(ans,num)
print(ans)