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



Sample input:
2
1 4


Sample output:
5

Submission status: Wrong Answer

Solution code:
a=int(input())
b=list(map(int,input().split()))
c=sum(b)//a
d=0
for i in b:
    d+=(i-c)**2
    
print(d)

Submission status: Wrong Answer

Solution code:
a=int(input())
b=list(map(int,input().split()))
c=(sum(b)//a)**2
print(c)

Submission status: Wrong Answer

Solution code:
a=2
n = int(input())
x = list(map(int, input().split())) 
ans =0

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


print(ans)

Submission status: Wrong Answer

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

sum = 0
for x in X:
    sum += x
avg = sum // n

ans = 0
for x in X:
    ans += pow((x-avg), 2)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

n = readInt()
x = readInts()

ans = 100000000

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

n = readInt()
x = readInts()

ans = 100000000

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

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
xs=list(map(int,input().split()))
p=sum(xs)//n
print(p)
hp,hq=0,0
for i in xs:
    hp+=(i-p)**2
    hq+=(i-p-1)**2
print(min(hp,hq))

Submission status: Wrong Answer

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


ans = float("inf")
for i in range(N):
    conf_site = X[i]
    total = sum([(x - conf_site)**2 for x in X])
    ans = min(ans, total)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
x = list(map(int,input().split()))
l =[]
dis = 0
for i in range(max(x)) :
    for a in x:
        dis += (i-a)**2
    l.append(dis)
    dis = 0
print(min(l))

Submission status: Wrong Answer

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

L = min(X)
R = max(X)

def ene(p):
  cost = 0
  for x in X:
    cost += (x - p) * (x - p)
  return cost

energy = float('inf')
while (L < R):
  energy = min([energy, ene(L)])
  L += 1
  
print(energy)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int,input().split()))
d = [0]*(max(X)+1-min(X))
for i in range(min(X),max(X)+1):
  for x in X:
    d[i-min(X)] += (x-i-min(X))**2
  if i > min(X) and d[i-min(X)] >= d[i-1-min(X)]:
    print(d[i-1-min(X)])
    exit(0)    
print(min(d))

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int,input().split()))
d = [0]*(max(X)+1-min(X))
for i in range(min(X),max(X)+1):
  for x in X:
    d[i-min(X)] += (x-i-min(X))**2
  if i > min(X) and d[i-min(X)] >= d[i-1-min(X)]:
    print(d[i-1-min(X)])
    exit(0)    
print(d[-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
p = int(sum(x)/len(x))

x =[(i-p)**2 for i in x]
print(sum(x))

Submission status: Wrong Answer

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

ans=1145141919
for p in range(max(x)):
    tmp_ans=0
    for i in range(n):
        tmp_ans+=(x[i]-p)**2
    ans=min(ans,tmp_ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
point_list = list(map(int, input().split()))
hp_list = []
for p in range(max(point_list)):
    hp = 0
    for i in range(len(point_list)):
        hp += (point_list[i] - p) ** 2
    hp_list.append(hp)
print(min(hp_list))

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
X = list(map(int,input().split()))
P = math.ceil(sum(X)/N)

hp = 0

for x in X:
  hp_x = (P-x)**2
  hp = hp + hp_x
print(hp)

Submission status: Wrong Answer

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

mn = min(X)
mx = max(X)

ans = []
hps = []
for i in range(X[-1]):
    for x in X:
        hps.append((x - i) ** 2)
    ans.append(sum(hps))
    hps = []

print(min(ans))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import combinations
def run():
    N, *X = list(map(int, read().split()))
    A = sum(X)
    B = sum([val ** 2 for val in X])
    if A%N == 0:
        print(B)
    else:
        p = A // N
        alpha = min(abs(p - A/N), abs(p - A/N + 1)) ** 2 * N + B - A ** 2 / N
        print(round(alpha))


if __name__ == "__main__":
    run()

Submission status: Wrong Answer

Solution code:

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

x_start = x_list[0]
x_end = x_list[-1]

min_count = 1e1000
for i in range(x_start, x_end + 1):
    count = 0
    for x in x_list:
        count += (x - i) * (x - i)
    if count < min_count:
        min_count = count

print(min_count)

Submission status: Wrong Answer

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

cnt_min = 9999

for P in range(1, 101):
  cnt = 0
  for x in X:
    cnt += (P-x)**2
    
  if cnt < cnt_min:
    cnt_min = cnt
  
print(cnt_min)

Submission status: Wrong Answer

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

cnt_min = 9999

for P in range(0, 101):
  cnt = 0
  for x in X:
    cnt += (P-x)**2
  if cnt < cnt_min:
    cnt_min = cnt
  
print(cnt_min)

Submission status: Wrong Answer

Solution code:
P = int(input())
X = list(map(int, input().split()))

cnt = 0
for x in X:
  cnt += (P-x)**2
  
print(cnt)

Submission status: Wrong Answer

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

ans = []

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

print(min(ans))

Submission status: Wrong Answer

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

ans = float("inf")

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

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
x_ = list(map(int,input().split()))

cnt = 0
res_ = []
for i in range(0,x_[n-1]+2):
    cnt = 0
    for j in range(len(x_)):
        cnt += (x_[j] - i)**2
    res_.append(cnt)

print(min(res_))

Submission status: Wrong Answer

Solution code:
n = int(input())
X = list(map(int, input().split()))
for p in range(max(X)):
    sum = 0
    for x in X:
        sum += ((x - p)**2)
    if p == 0:
        ans = sum
    if ans > sum:
        ans = sum
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
X = list(map(int,input().split()))

A = math.ceil(sum(X)/N)
B = math.floor(sum(X)/N)

a = 0
b = 0

for i in X:
  a += (i-A)**2
  
for _ in X:
  b += (i-B)**2
  
print(min(a,b))

Submission status: Wrong Answer

Solution code:
# C - Rally
# https://atcoder.jp/contests/abc156/tasks/abc156_c


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

total = 0


for num in nums:
    total += (num - p) ** 2

print(total)

Submission status: Wrong Answer

Solution code:
N = int(input())
l = map(int, input().split())

mean = int(sum(l)/N)

stamina = 0

for p in l:
	stamina += (p - mean)**2
    
print(stamina)

Submission status: Wrong Answer

Solution code:
N = int(input())
Xs = list(map(int,input().split()))
ans = 0
ansCandidate = 0
for j in range(min(Xs),max(Xs)):
    ansCandidate = 0
    for i in range(N):
        ansCandidate += (Xs[i] - j)**2
    print(ansCandidate)
    if j == min(Xs):
        ans = ansCandidate
    ans = min(ans,ansCandidate)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil
n = int(input())
nums = [int(i) for i in input().split()]
avg = ceil(sum(nums)/len(nums))
print(sum([(num-avg)**2 for num in nums]))

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = [int(i) for i in input().split()]
print(min([sum([(num-i)**2 for num in nums]) for i in range(1,n+1,1)]))

Submission status: Wrong Answer

Solution code:
n = int(input())
num_list = list(map(int, input().split()))

ans_list = [0] * max(num_list)
for i in range(max(num_list)):
    for j in range(n):
        ans_list[i] += ((num_list[j] - i)**2)

print(min(ans_list))

Submission status: Wrong Answer

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

ans = 10 ** 99
ansp = 0

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

Submission status: Wrong Answer

Solution code:
N=int(input())
x=list(map(int, input().split()))
M=max(x)

dmin=M**2
for p in range(1,M+1):
  d=0
  for i in range(N):
    d+=(p-x[i])**2
  if d<=dmin:
    dmin=d
print(dmin)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=list(map(int,input().split()))
ans1=sum(x)
ans2=0
ans=100000
for i in range(n):
  ans2+=x[i]**2
for p in range(1,max(x)+1):
  ans=min(ans,n*p*p+ans2-2*p*ans1)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
xl = tuple((int(x)for x in input().split()))
mi,ma = min(xl), max(xl)
ans = ma ** 2 + mi ** 2
for x in range(mi+1, ma):
    p = sum(((i-x)**2 for i in xl))
    if ans > p:
        ans = p
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int,input().split()))
ans = 10**5
c = int()
for i in range(1,100+1):
    c = 0
    for j in range(len(X)):
        c += (X[j]-i)**2
    if c <= ans:
        ans = c
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int,input().split()))
ans = 10**5
c = int()
for i in range(1,100):
    c = 0
    for j in range(len(X)):
        c += (X[j]-i)**2
    if c <= ans:
        ans = c
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def calc_sum_of_power(N, coord):
    spot = round(sum(coord)/N)
    return sum([(x - spot)**2 for x in coord])

def main():
    N = int(input())
    coord = map(int, input().split())
    print(calc_sum_of_power(N, coord))

if __name__ == "__main__":
    try:
        assert calc_sum_of_power(2, [1, 4]) == 5
        assert calc_sum_of_power(7, [14, 14, 2, 13, 56, 2, 37]) == 2354
    except:
        import traceback
        traceback.print_exc()
        exit()
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
X = [int(x) for x in input().split()]
result = -1
for i in range(1,max(X)):
  total = 0
  for n in range(N):
    total += (X[n]-i)**2
  if result==-1:
    result=total
  if total<result:
    result=total
print(result)

Submission status: Wrong Answer

Solution code:
import numpy as np

def calc(X, p):
  ans = 0
  for x in X:
    ans += (x-p)**2   
  print(ans)
  
n = int(input())
X = list(map(int, input().split()))

p = np.mean(X)
p1 = np.floor(p)
p2 = np.ceil(p)

if p <= p1 + 0.5:
  calc(X, p1)
else:
  calc(X, p2)

Submission status: Wrong Answer

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

ans = 1000000
for i in range(max(x)):
  l = 0
  for j in range(n):
    l += (x[j]-i)**2
  if ans > l:
    ans = l
    
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
xi = list(map(int, input().split()))

cost = []
for p in range(max(xi)):
    tmp = 0
    for i in xi:
        tmp += pow((p - i), 2)
    cost.append(tmp)

print(min(cost))

Submission status: Wrong Answer

Solution code:
def main(n, xi):
    res = []
    for i in range(1,n+1):
        f = 0
        for j in xi:
            f += pow((i - j), 2)
        res.append(f)

    return min(res)

n = int(input())
xi = list(map(int, input().split()))
print(main(n,xi))

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

for i in range(max(x)):
    a = 0
    for j in range(n):
        a += (x[j]-i)**2
    if i == 0:
        ans += a
    else:
        ans = min(a, ans)

print(ans)

Submission status: Wrong Answer

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

ans = 1000000000

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

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
xlist=list(map(int,input().split(" ")))
count=100000

for kaisai in range(101):
    sum=0
    for hito in xlist:
        sum+=(hito-kaisai)**2
    #print(sum)
    if sum<count:
        count=sum
print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
s=[]
for i in range(10):
  m=0  
  for j in range(0,len(a)):
    m+=(a[j]-i)**2
  s.append(m)
print(min(s))

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
s=[]
for i in range(101):
  for j in range(0,len(a)):
    m=0
    m+=(a[j]-i)**2
    s.append(m)
print(min(s))

Submission status: Wrong Answer

Solution code:
def II(): return int(input())
def MI(): return map(int,input().split())
def LMI(): return list(map(int,input().split()))
def LIIN(n): return list(int(input()) for _ in range(n))
def LMIN(n): return [list(map(int, input().split())) for _ in range(n)]
def IS(): return input()
def MS(): return map(str,input().split())
def LMS(): return list(map(str,input().split()))
def LISN(n): return list(input() for _ in range(n))
def LMSN(n): return [input().split() for _ in range(n)]
MOD = 10**9+7
INF = 10**18

def main():
    n = II()
    x = LMI()
    a = (sum(x)+len(x)-1) // len(x)
    print(sum([(i-a)**2 for i in x]))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(x) for x in input().rstrip().split()]
ave=sum(A)//len(A)
ans=0
print(ave)
if N/2<(sum(A)%len(A)):
  ave+=1

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = 100**3
ma = max(a)
for i in range(1,ma):
    sum = 0
    for j in range(n):
        sum += (a[j]-i)**2
    if ans > sum:
        ans = sum

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
X=map(int, input().split())
cost=0
for u in X:
  cost += abs(u-N)**2
print(cost)

Submission status: Wrong Answer

Solution code:
N=int(input())
X=map(int, input().split())
uniq = [x for x in X if x != N]
cost=0
for u in uniq:
  cost += abs(u-N) * abs(u-N)
print(cost)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=list(map(int,input().split()))
ans=10000000000000000

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

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=list(map(int,input().split()))
ans=10**9
average=sum(x)//n

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

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=list(map(int,input().split()))
ans=0
average=sum(x)//n

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

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

x = [0] * n

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

x.sort()
sum = 0
min_sum = 100 * 1000
for i in list(range(x[0], x[-1] + 1)):
    sum = 0
    for j in x:
        sum += (j - i) * (j - i)
    if sum < min_sum:
        min_sum = sum
    # else:
    #     break
print(min_sum)

Submission status: Wrong Answer

Solution code:
n = int(input())

x = [0] * n

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

x.sort()
sum = 0
min_sum = 100 * 1000
for i in list(range(x[0], x[-1] + 1)):
    sum = 0
    for j in x:
        sum += (j - i) * (j - i)
    if sum < min_sum:
        min_sum = sum
    else:
        break
print(min_sum)

Submission status: Wrong Answer

Solution code:
n = int(input())

x = [0] * n

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

x.sort()
sum = 0
min_sum = 100 * 1000
for i in list(range(x[0], x[-1] + 1)):
    sum = 0
    for j in x:
        sum += (j - i) * (j - i)
    if sum < min_sum:
        min_sum = sum
    else:
        print(i)
        break
print(min_sum)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

# check
ans = 0
for i in range(1, max(X), 1):
    sub_life = sum([(j - i) ** 2 for j in X])

    if i == 1 or ans > sub_life:
        ans = sub_life

print(ans)

Submission status: Wrong Answer

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

# check
ans = 0
for i in range(max(X)):
    sub_life = sum([(j - i) ** 2 for j in X])

    if ans == 0 or ans > sub_life:
        ans = sub_life

print(ans)

Submission status: Wrong Answer

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

# check
ans = 0
for i in range(1, max(X), 1):
    sub_life = sum([(j - i) ** 2 for j in X])

    if ans == 0 or ans > sub_life:
        ans = sub_life

print(ans)

Submission status: Wrong Answer

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

# check
ans = -1
for i in range(max(X)):
    sub_life = 0
    for j in X:
        sub_life += (j - i) ** 2

    if ans == -1 or ans > sub_life:
        ans = sub_life

print(ans)

Submission status: Wrong Answer

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

# check
ans = 0
for i in range(1, max(X), 1):
    sub_life = 0
    for j in X:
        sub_life += (j - i) ** 2

    if ans == 0 or ans > sub_life:
        ans = sub_life

print(ans)

Submission status: Wrong Answer

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

# check
ans = 0
for i in set(X):
    sub_life = 0
    for j in X:
        sub_life += (j - i) ** 2
    
    if ans == 0 or ans > sub_life:
        ans = sub_life

print(ans)

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
x=list(map(int,input().split()))
y=[]
x_avr=sum(x)/n
for i in range(n):
    y.append(math.pow((x_avr-x[i]),2))
print(math.ceil(sum(y)))

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
x=list(map(int,input().split()))
y=[]
x_avr=sum(x)/n
for i in range(n):
    y.append(math.pow((x_avr-x[i]),2))
print(int(sum(y)+1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
X=[int(i) for i in input().split()]
if sum(X)%len(X)>=0.5:
    avg=(sum(X)//len(X))+1
else:
    avg=sum(X)//len(X)
summy=0
for i in X:
    summy+=(i-avg)**2
print(summy)

Submission status: Wrong Answer

Solution code:
import math

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

mean = math.ceil(sum(x) / n)

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

if sum(x) % n != 0:
	ans2 = 0
	for i in range(n):
		ans2 += (x[i]-mean) ** 2

	print(min(ans1,ans2))
else:
	print(ans1)

Submission status: Wrong Answer

Solution code:
import math

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

mean = math.ceil(sum(x) / n)

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

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

print(min(ans1,ans2))

Submission status: Wrong Answer

Solution code:
import sys

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

mean = sum(x) // n

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

Submission status: Wrong Answer

Solution code:
N = int(input())
x = list(map(int,input().split()))

l=[]

for p in range(1,N+1):
  sum=0
  
  for i in range(N):
    sum += (x[i]-p)**2
  
  l.append(sum)
  
print(sorted(l)[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
ans = 10**9
for i in range(1,101):
    b = sum((a[j]-i-1)**2 for j in range(0,N))
    ans = min(ans,b)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
ans = 10**4
for i in range(1,101):
    b = sum((a[j]-i-1)**2 for j in range(0,N))
    ans = min(ans,b)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
ans = 10**4
for i in range(1,N+1):
    b = sum((a[j]-i-1)**2 for j in range(0,N))
    ans = min(ans,b)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
s = []
for i in range(1,N+1):
    b = sum((a[j]-i)**2 for j in range(0,N))
    s.append(b)
print(min(s))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
s = []
for i in range(1,N+1):
    b = sum((a[j]-i)**2 for j in range(0,N))
    s.append(s)
print(min(s))

Submission status: Wrong Answer

Solution code:
n = int(input())
hp = list(map(int,input().split()))
a = []
for i in range(0,n):
  s = sum((hp[j]-i-1)**2 for j in range(0,n))
  a.append(s)

print(min(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
hp = list(map(int,input().split()))
a = []
for i in range(0,n):
  s = 0
  for j in range(0,n):
    s+=(hp[j]-i-1)**2
  a.append(s)
  
print(min(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int, input().split()))
m = 10**5
for p in range(1, max(l)+1):
    tmp = 0
    for x in l:
        tmp += (x-p)**2
    m = min(m, tmp)

print(m)

Submission status: Wrong Answer

Solution code:
n = int(input())
X = list(map(int, input().split()))
ans = 0

for i in range(1,101):
  tmp = 0
  for x in X:
    if i == 1:
      ans += (i - x)**2
    else:
      tmp += (i - x)**2
      if tmp < ans:
        ans = tmp
    
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
su=0
for i in range(n):
  su+=l[i]
su=su//n
ans=0
for i in range(n):
  ans+=(l[i]-su)**2
print(ans)

Submission status: Wrong Answer

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

mx=99999999999999999999999999
su=0
for i in range(n):
  su=0
  for j in range(n):
    su+=(l[j]-(i+1))*(l[j]-(i+1))
  if su<=mx:
    mx=su
print(su)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=list(map(int, input().split()))
min_=10**9
for i in range(min(x),max(x)+1,1):
  #print(i)
  sum_=0
  for j in range(n):
    sum_+=(x[j]-i)**2
  if sum_<min_: min_=sum_
  print(min_)
print(int(min_))

Submission status: Wrong Answer

Solution code:
n=int(input())
x=list(map(int, input().split()))
min_=10**9
for i in range(min(x),max(x),1):
  sum_=0
  for j in range(n):
    sum_+=(x[j]-i)**2
  if sum_<min_: min_=sum_
print(min_)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
M = max(x)
s = [0]*(2*M)

for j in range(2*M):
	for i in range(n):
		s[j] += pow(x[i]-(j-M),2)
print(min(s))

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
M = max(x)
s = [0]*M

for j in range(M):
	for i in range(n):
		s[j] += pow(x[i]-j,2)
print(min(s))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int, input().split()))
ans = 10 ** 10
for i in range(min(l), max(l)):
    can = 0
    for j in l:
        can += (j - i) ** 2
    if can < ans:
        ans = can
print(int(ans))

Submission status: Wrong Answer

Solution code:
import math
def main():
  N=int(input())
  X=list(map(int,input().split()))
  x_mean=math.ceil(sum(X)/len(X))
  sumX=0
  for i in range(len(X)):
    sumX=sumX+(X[i]-x_mean)**2
  print(sumX)

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

average = sum(A) // N
ans1 = 0
for i in A:
    ans1 += (i-average)**2
ans2 = 0
for i in A:
    ans2 += (i-average+1)**2
ans = min(ans1, ans2)

print(ans)

Submission status: Wrong Answer

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

average = sum(A) // N
ans1 = 0
for i in A:
    ans1 += (i-average)**2
ans2 = 0
for i in A:
    ans2 += (i-average)**2
ans = min(ans1, ans2)

print(ans)

Submission status: Wrong Answer

Solution code:
import statistics

N = int(input())
X = [int(i) for i in input().split()]
X.sort()
mid = statistics.mean(X)
ans = 0
ans1 = 0
ans2 = 0
print(mid)
for i in range(N):
    ans1 += (X[i] - int(mid)) ** 2
    ans2 += (X[i] - int(mid) - 1) ** 2
ans = min(ans1, ans2)

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
lmax=0
for i in range(n):
    if lmax<l[i]:
        lmax=l[i]
sumlist=[]
for i in range(lmax):
    sumlist.append(0)
total=0
for i in range(lmax):
    for j in range(n):
        t=(l[j]-i)*(l[j]-i)
        total+=t
    sumlist[i]=total
    total=0
min=10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
for i in range(lmax):
    if min>sumlist[i]:
        min=sumlist[i]
print(min)