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-----
2
1 4

-----Sample Output-----
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.

Difficulty: introductory

Starter code:

Solutions:
import numpy as np
N = int(input())
Xi = list(map(int, input().split()))
Xi = np.array(Xi)
min = float('inf')
for i in range(1, 101):
    tmp = np.sum(np.square(Xi - i))
    if tmp < min:
        min = tmp
print(min)

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

for p in range(min(x), max(x)+1):
    sum = 0
    for i in x:
        sum = sum + (i-p)**2 
    hp.append(sum)
    
print(min(hp))

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

p = sum(x)//n
e1 = 0
e2 = 0
for i in x:
    e1 += (p-i)**2
    e2 += (p+1-i)**2
print(min(e1, e2))

n=int(input())
h=list(map(int,input().split()))
mnx=-1
mxx=10**8
avg=sum(h)//len(h)
avgx=avg+1
s1=0
s2=0
for i in h:
  s1+=((i-avg)**2)
  s2+=((i-avgx)**2)
print(min(s1,s2))

N = int(input())
X = list(map(int,input().split()))
min = 100*10000

for p in range(100):
    sum = 0
    for i in X:
        sum += (i-p)**2
    if sum < min:
        min = sum

print(min)

n = int(input())
L = list(map(int,input().split()))
l,r,ans = min(L),max(L),10**18

for i in range(l,r+1):
  total = 0
  for l in L:
    total += (l-i)**2
  ans = min(ans, total)
print(ans)

n = int(input())

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

for i in range(1, n+1000):
  count = 0
  for j in range(n):
    count += (x[j]-i)*(x[j]-i)
  if i == 1:
    min = count
  elif count < min:
    min = count
  else:
    break

print(min)

n = int(input())

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

h = round(sum(x) / n)

ans = 0

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

print(ans)

import os, sys, re, math

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

d = [i ** 2 for i in range(101)]

min_v = 100 ** 2 * 100
for i in range(1, 101):
    min_v = min(min_v, sum(d[abs(x - i)] for x in X))

print(min_v)


n = int(input())
x = list(map(int,input().split()))
d= float("inf")
for i in range(max(x)+1):
    c=0
    for j in range(len(x)):
        c+=(x[j]-i)**2
    d=min(c,d)
print(d)

N = int(input())
A = [int(x) for x in input().split()]
count = 0
for j in range(len(A)):
    count += pow(A[j] - round(sum(A) / len(A)),2)
print(count)

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

P = int(sum(X)/N+.5)
print(sum((x-P)**2 for x in X))

N=int(input())
X=sorted(list(map(int,input().split())))
Y=[0]*(max(X)-min(X)+1)
for i in range(max(X)-min(X)+1):
  for j in X:
    Y[i]+=(j-i-min(X))**2
print(min(Y))

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

min_x = 100 * 100 * 100 + 1
for p in range(1, 100+1, 1):
  total = 0
  for xi in x:
    total += (xi - p) ** 2

  min_x = min([min_x, total])

print(min_x)



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

x_max = max(x)
x_min = min(x)
hp_min = 10000*100

for p in range(x_min, x_max + 1):
    hp = 0
    for x_i in x:
        hp += (x_i - p)**2
    if hp < hp_min:
        hp_min = hp
    
print(hp_min)

n = int(input())
x = list(map(int, input().split()))
hp_min = 10000000
for i in range(101):
	hp_min = min(hp_min, sum((y-i) ** 2 for y in x))
print(hp_min)

n = int(input())
x = [int(i) for i in input().split()]
ave = sum(x) // n
ansl = 0
ansr = 0

for i in x:
    ansl += pow(i - ave, 2)
    ansr += pow(i - ave - 1, 2)

print(min([ansl, ansr]))

import math
N = int(input())
lst = list(map(int, input().split()))
X = math.floor(sum(lst)/N + 0.5)
ans = 0
for i in lst:
    ans = ans + (X - i)**2

print(ans)

n=int(input())
x=list(map(int,input().split()))
max_x=max(x)
min_x=min(x)
f=0
ans=1000000
for p in range(min_x,max_x+1):
    for i in range(n):
        f+=(x[i]-p)**2
    else:
        ans=min(ans,f)
        f=0
print(ans)

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

ans = 1000000
for i in range(100):
    tmp = 0
    for j in range(n):
        tmp += (x[j]-(i+1))**2
        
    ans = min(ans, tmp)
    
print(ans)

N = int(input())
X_ls = list(map(int, input().split(' ')))
rst = -1
for i in range(min(X_ls), max(X_ls) + 1):
    val = 0
    for j in X_ls:
        val += (i - j) ** 2
    if rst == -1:
        rst = val
    else:
        rst = min(rst, val)
print(rst)

N = int(input())
X = list(map(int,input().split()))
T = sum(X) // len(X)
a = 0
b = 0
c = 0
for i in X:
    a += (i - T)**2
    b += (i - T -1)**2
    c += (i - T+1)**2

ans = min(a,b)
print(min(ans,c))

N=int(input())
X_list=list(map(int,input().split()))
distance=10**9

min_val=min(X_list)
max_val=max(X_list)
P_list=list(range(min_val,max_val+1))

for _ in range(N):
  for p in P_list:
    temp=0
    for x in X_list:
      temp+=(p-x)**2
    if temp<distance:
      distance=temp

print(distance)

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

ans = 10**9

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

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

min = 2**20

for p in range(100):
    min_i = 0
    if p in x:
        continue
    for i in x:
        min_i = min_i + (int(i) - p)**2
    if min_i <= min:
        min = min_i
print(min)

N = int(input())
X = list(map(int, input().split()))
small = 10000000
temp = 0
p_max = max(X)

for p in range(1, p_max + 1):
  for i in range(N):
    temp += (X[i] - p)**2
    
  if temp < small:
    small = temp
  
  temp = 0
  
print(small)


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

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

min_y = 9999999999

for p in range(min_x, max_x+1):
    y = sum([(x - p)**2 for x in X])
    if y < min_y:
        min_y = y

print(min_y)


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

if N == 1:
  print(0)

elif X[0] == X[-1]:
  print(0)

else:
  sum = [0] * (X[-1] - X[0])

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

  print(min(sum))

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


n = int(input())
l = list(map(int, input().split()))
ans = 1000000
for p in range(1,101):
  d = 0
  for x in l:
    d += (x-p)**2
  ans = min(d,ans)
print(ans)

n = int(input())
x = list(map(int,input().split()))
ans = []
if len(set(x)) == 1:
    print(0)
else: 
    for p in range(min(x), max(x)):
        meter = 0
        for xi in x:
            meter += pow((xi-p),2)
        ans.append(meter)
    print(min(ans))

n = int(input())
x = list(map(int, input().split()))
s = 0
for i in x:
  s += i
p = int(s/n + 0.5)
result = 0
for i in x:
  result += (i-p)**2
print(result)

N = int(input())
X = list(map(int, input().split()))
MIN = 100**3

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

print(MIN)


n=int(input())
a=[*map(int,input().split())]
d=[]
for i in range(min(a),max(a)+1):
  temp=[]
  for j in range(n):
    temp.append((a[j]-i)**2)
  d.append(sum(temp))
print(min(d))

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

n  = int(input())
x_list = list(map(int,input().split()))
my_func = lambda x: int((x * 2 + 1) // 2)
x_list_mean= my_func((sum(x_list)/len(x_list)))
count = 0 
for i in x_list:
    count += (i-x_list_mean)**2
print(count)

a = int(input())
b = input().split()
b = [int(j) for j in b]
x = round(sum(b) / a)
y = []
for i in range(a):
    y.append((x - b[i])**2)
print(sum(y))

n = int(input())
X = list(map(int, input().split()))
x_min = min(X)
x_max = max(X)

min_val = 10**6 + 1

for i in range(x_min, x_max + 1):
    min_val = min(min_val, sum(map(lambda x: (x-i)**2, X)))

print(min_val)

n = int(input())
x = list(map(int, input().split()))
sum= 1000000000000000
for p in range(1,101):

    tmp=0
    # print("p",p)
    for i in range(len(x)):
        tmp += (x[i] - p)**2
        # print("tmp",tmp)
    sum = min(sum,tmp)
    # print("su",sum)
print(sum)

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

P = round(sum(x_list) / N)
ans = 0

for i in x_list:
    ans += (i - P) ** 2

print(ans)

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

ans=n * 100**2
for p in range(101):
    ans=min(ans,sum([(xi-p)**2 for xi in x]))
print(ans)


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

p = round(sum(x) / n)
print(sum([(x[i] - p)**2 for i in range(n)]))

N=int(input())
X=sorted(list(map(int,input().split())))
Y=[0]*(max(X)-min(X)+1)
s=0
for i in range(max(X)-min(X)+1):
  for j in X:
    Y[i]+=(j-i-min(X))**2

print(min(Y))

import numpy as np

n = int(input())
x = list(map(int, input().split()))
p = round(np.mean(x))
cost = np.dot(np.array(x) - p, np.array(x) - p)
print(int(cost))

N = int(input())
X = list(map(int, input().split()))
P = round(sum(X)/N)
ans = sum(list(map(lambda x: (x-P)**2, X)))
print(ans)

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

X_min = min(X)
X_max = max(X)

ans = float('inf')
for i in range(X_min, X_max + 1):
    d = 0
    for x in X:
        d += (x - i) ** 2
    ans = min(ans, d)

print(int(ans))
return

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

def answer(N,XN):
    a = min(XN)
    b = max(XN)
    min_distance = float('inf')
    for i in range(a,b+1):
        distance = 0
        for j in XN:
            distance += (i-j) ** 2
        min_distance = min(distance,min_distance)
    print(min_distance)

answer(N,XN)

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

#!/usr/local/bin/python3

import math

def power(P, X):
    ans = 0
    for x in X:
        ans += (x-P)**2
    return ans

N = int(input())
X = list(map(int, input().split()))
ave = sum(X)/N
candP = (math.ceil(ave), math.floor(ave))
power = min([power(P, X) for P in candP])

print(power)


N = int(input())
X = input().split()

distance = 0
min_distance = float('Inf')

for i in range(1,101):
    for j in range(N):
        distance += (int(X[j]) - i) ** 2

    min_distance = min(min_distance, distance)
    distance = 0

print(min_distance)

N = int(input())

l = []
l = list(map(int, input().split()))

s = sum(l)
# find a place to hold the meeting
n = int((s/N*2 + 1)//2)

ans = 0
for e in l:
    ans += (e-n)**2

print(ans)


import math
import numpy as np

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

lower = min(X)
upper = max(X)
ans = (X-lower)**2
ans = ans.sum()

for i in range(lower+1, upper+1):
    m = (X-i)**2
    if m.sum() < ans:
        ans = m.sum()

print(ans)


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


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

N = int(input())
X = [int(_) for _ in input().split()]
ans = 10**6
for i in range(min(X),max(X)+1):
    p = 0
    for j in range(N):
        p += (X[j]-i)**2
    ans = min(ans,p)
print(ans)

n = int(input())
arr = list(map(int, input().split()))
s = sum(arr)*2
z = round(s / (2*n))
for k in range(n):
    arr[k] = (arr[k]-z) ** 2
print((sum(arr)))


n=int(input())
x_list=list(map(int,input().split()))
ave = sum(x_list)/n
p = int(ave) + (1 if ave - int(ave) > 1/2 else 0)
ans = sum([(p - x_i)**2 for x_i in x_list])
print(ans)

N=int(input())
X=list(map(int,input().split()))
cost= 10**18
for i in range(1,101):
    cost_count=0
    for j in range(N):
        cost_count +=(X[j]-i)**2
    if cost > cost_count:
        cost = cost_count
    else:
        pass
print(cost)

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

ans = float("inf")
for i in range(1, max(X) + 1):
  tmp = 0
  for j in range(N):
    tmp += pow(X[j] - i, 2)
  ans = min(ans, tmp)
print(ans)

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

cnt_m = float('inf')
for i in range(1, 101):
    cnt = 0
    for j in range(n):
        cnt += (l[j] - i) ** 2
    cnt_m = min(cnt_m, cnt)

print(cnt_m)

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

total = 0
m = round(sum(X) / N)

for i in X:
    total += (m - i) ** 2
print(total)

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

def main():
	n = int(input())
	x = [int(v) for v in input().split()]
	x.sort()
	closest = x[0]
	farest = x[-1]
	startPoint = 0
	sofar = float('inf')
	for i in range(0, farest+1):
		p = i
		cur = 0
		for j in range(len(x)):
			cur += (x[j] - p)**2
		if cur < sofar:
			sofar = cur
	return sofar





def __starting_point():
    print((main()))

__starting_point()

import math
N = int(input())
Xlist = list(map(int,input().split()))

min =10**5
meandown = math.floor(sum(Xlist)/N)
meanup = math.ceil(sum(Xlist)/N)
sumdown=0
sumup = 0
for i in range(len(Xlist)):
  sumdown+= (Xlist[i]-meandown)**2
  sumup+= (Xlist[i]-meanup)**2
  
if sumdown<sumup:
  print(sumdown)
else:
  print (sumup)

n = int(input())

ans = 10**7+9

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

X = len(x)

for i in range(100):
    total = 0
    for j in range(X):
        total += (x[j]-i)**2
    else:
        ans = min(ans,total)

print(ans)


N = int(input())
X = list(map(int, input().split()))
_min = min(X)
_max = max(X)
_sum = 1000000000
for i in range(_min, _max+1):
    temp = 0
    for x in X:
        temp += (x - i) * (x - i)
    if temp < _sum:
        _sum = temp
print(_sum)


n=int(input())
x=list(map(int,input().split()))
num=0
for i in x:
    num+=i
num=round(float(num/n))
ans=0
for i in x:
    ans+=(i-num)**2
print(ans)

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

ave = 0

for i in X:
    ave += i
if ((ave/N) // 0.5) % 2 == 1:
    ave = (ave //N) + 1
else:
    ave = ave // N

ans = 0
for i in X:
    ans += (ave - i)**2
print(ans)

def resolve():
	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)
resolve()

N=int(input())
x= [int(i) for i in input().split()]
y=0
d=0
for n in x:
  y+=n
z=y//N
if y/N-z>=0.5:
  g=z+1
else:
  g=z
for s in x:
  d+=(s-g)**2
print(d)

n = int(input())
x = [int(s) for s in input().split()]
a = []
for i in range(min(x), max(x) + 1):
    ans = 0
    for j in range(n):
        ans += (i - x[j]) ** 2
    a.append(ans)
print(min(a))

N=int(input())
X=list(map(int, input().split()))
import numpy as np
p=np.floor(np.mean(X))
ans=min(np.sum([(x-p)**2 for x in X]), np.sum([(x-(p+1))**2 for x in X]))

print(int(ans))

n=int(input())
x_list=list(map(int,input().split()))
ave = sum(x_list)/n
p = int(ave) + (1 if ave - int(ave) > 1/2 else 0)
ans = sum([(p - x_i)**2 for x_i in x_list])
print(ans)

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

ans = 1e10
for p in range(max(X)+1):
    sum_power = 0
    for i in range(N):
        sum_power += (X[i]-p)**2
    if ans > sum_power:
        ans = sum_power

print(ans)

import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n = k()
x = l()
a = sum(x)//n
b = sum(x)//n + 1

for i in x:
  ans += pow(i-a,2)
  cnt += pow(i-b, 2)

print(min(ans,cnt))

n = int(input())
x = list(map(int, input().split()))
ans = float('inf')
mxi = min(x)
mxa = max(x)
for p in range(mxi, mxa+1):
    sm = 0
    for xi in x:
        sm += (xi-p)**2
    ans = min(ans, sm)
print(ans)

import numpy as np
N = int(input()) 
X_ls = np.array(list(map(int, input().split())))

#N=2
#X_ls =np.array( [1,4])

ans = 0
for p in range(max(X_ls)+1):
    sub = X_ls-p
    ans_1 = sum(sub**2)
    if ans_1 <= ans or ans ==0:
        ans = ans_1
print(ans)

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

ans = float("inf")
for p in range(1,101):
    hp = 0
    for i in x:
        hp += (i-p)**2
    ans = min(ans, hp)
print(ans)

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

ans=10**1000
for p in range(X[0],X[-1]+1):
    tmp=0
    for x in X:
        tmp+=(x-p)**2
    ans=min(ans,tmp)
print(ans)

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

list1.sort()
x=list1[0]
y=list1[-1]

s=0
list2=[]
while x+s<=y:
    list2.append(x+s)
    s=s+1

list3=[]
for j in list2:
    w=0
    for i in list1:
        w=w+(i-j)*(i-j)
    list3.append(w)

list3.sort()
print((list3[0]))


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

D = [(x - round(sum(X)/N))**2 for x in X]

print(sum(D))

input()
x=list(map(int,input().split()))
r=10**10
for i in range(min(x),max(x)+1):
	s=0
	for j in x:
		s+=(i-j)**2
	r=min(r,s)
print(r)

n = int(input())
x = list(map(int,input().split()))
ave = sum(x) // len(x)
ans_list = []
ans_list2 = []
for i in x:
    ans = (i - ave)**2
    ans_list.append(ans)
ans1 = sum(ans_list)

ave2 = ave + 1
for i in x:
    ans = (i - ave2)**2
    ans_list2.append(ans)
ans2 = sum(ans_list2)
if ans1 < ans2:
    print(ans1)
else:
    print(ans2)

N = int(input())
X = list(map(int, input().split()))
ans = 10**18

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

print(ans)




N=int(input())
x= [int(i) for i in input().split()]
y=0
d=0
for n in x:
  y+=n
z=y//N
if y/N-z>=0.5:
  g=z+1
else:
  g=z
for s in x:
  d+=(s-g)**2
print(d)


N = int(input())
X = list(map(int,input().split()))
ans = 10**6

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

print(ans)

import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    L = LI()
    num = math.ceil(sum(L)/N)
    ans = 0
    ans2 = 0
    
    for i in L:
        ans+=pow(i-num, 2)
        ans2+=pow(i-num+1, 2)
    print(min(ans, ans2))
def __starting_point():
    main()
__starting_point()

N=int(input())
list1 =list(map(int,input().split()))
list1.sort()
max = list1[-1]
min = list1[0]
cost = []
for i in range(min,max+1):
  tairyoku = 0
  for k in range(N):
    tairyoku += (list1[k]-i)**2
  cost.append(tairyoku)
cost.sort()
print(cost[0])

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

lst.sort()
M = lst[-1]
m = lst[0]
total = float('inf')

for i in range(m,M+1):
  s = sum([(x-i)**2 for x in lst])
  if s < total:
    total = s
    
print(total)    


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

min = 2**50

for p in range(100):
    min_i = 0
    if p in x:
        continue
    for i in x:
        min_i = min_i + (int(i) - p)**2
    if min_i <= min:
        min = min_i
print(min)

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

m1 = sum(X) // n
m2 = (sum(X) + (n-1)) // n

a1 = sum([(x-m1)**2 for x in X])
a2 = sum([(x-m2)**2 for x in X])
print((min(a1,a2)))


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

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

min_X = min(X)
max_X = max(X)
ans = []
for i in range(min_X, max_X + 1):
    score = []
    for j in range(N):
        score.append((X[j] - i) ** 2)
    ans.append(sum(score))

print(min(ans))

# coding=utf-8

#lib
#import copy
#import collections
#import sys
'''
def generate_2d_array(Row, Column, IV):
    array = [[IV] * Column for i in range(Row)]
    return array


def search_in_2d_array(array, Row, Column, V):
    cnt = 0
    for i in range(Column):
        for j in range(Row):
            if array[i][j] == V:
                cnt += 1
    return cnt


def input_2d_array(Row, Column):
    array = generate_2d_array(Row, Column, 0)

    for i in range(Column):
        temp = list(map(int, input().split()))
        for j in range(Row):
            array[i][j] = temp[j]

    return array
'''

def __starting_point():
    N = int(input())
    Xli = list(map(int, input().split()))

    ans = float('inf')

    for i in range(101):
        cnt = 0

        for j in range(N):
            cnt += abs(Xli[j]-i)**2

        ans = min(ans, cnt)


    print(ans)
__starting_point()

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

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

a = 0
b = 0

N = int(input())
X = list(map(int, input().split()))
avg = sum(X) // N
for tai in X:
  a += (tai - avg) ** 2
for tai in X:
  b += (tai - (avg + 1)) ** 2
if a > b :
  print(b)
else :
  print(a)

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

a = sum(X)
b = 0
for num in X:
	b += num ** 2

ans = float('inf')
for i in range(1, 101):
	ans = min(ans, N * i * i - 2 * a * i + b)
print(ans)


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

ans_list = []

for i in range(min(X_list), max(X_list)+1):
    summarize = 0
    # print(f'i：{i}')
    for x in X_list:
        summarize += (x-i)**2
        # print(f'i: {i}, x: {x}, summarize: {summarize}')
    ans_list.append(summarize)
    # print(f'ans_list: {ans_list}')

print(min(ans_list))