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:
# template by 3xC and starkizard.
# contributors: 

#####################################################################################
from __future__ import division, print_function 

import sys
import os
from collections import Counter, deque, defaultdict
import itertools
import math
import io


"""Uncomment modules according to your need"""


# from bisect import bisect_left, bisect_right, insort
# from heapq import heappop, heapify, heappush
# from random import randint as rn
# from Queue import Queue as Q
# from copy import deepcopy
# from decimal import *
# import re
# import operator

#####################################################################################
# this enables you to write python3 code with PyPy2 (Python 2)
if sys.version_info[0] < 3:
    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip

#####################################################################################

"""value of mod"""
MOD = 998244353
mod = 10**9 + 7

"""Uncomment next 4 lines if doing huge recursion"""
# import threading
# threading.stack_size(1<<27)
# sys.setrecursionlimit(10000

def prepare_factorial(mod=mod):
    """ returns two lists, factorial and inverse factorial modulo argument by default 10**9 +7 """
    # Comment code out when you don't need inverse factorial or vice versa
    fact = [1]
    for i in range(1, 200005):
        fact.append((fact[-1] * i) % mod)

    ifact = [0] * 200005
    ifact[200004] = pow(fact[200004], mod - 2, mod)
    for i in range(200004, 0, -1):
        ifact[i - 1] = (i * ifact[i]) % mod
 
    return fact, ifact

def modinv(n, p):
    """ returns N inverse modulo p """
    return pow(n, p - 2, p)
 
def ncr(n, r,  fact, ifact):
    """ takes 4 arguments: n , r and factorial and inverse factorial lists"""
    t = (fact[n] * (ifact[r]*ifact[n-r]) % MOD)% MOD
    return t


def get_n(Sum):    
    """this function returns the maximum n for which Summation(n) <= Sum"""
    ans = (-1 + sqrt(1 + 8*Sum))//2
    return ans

def sieve(n):
    """ returns a list of prime numbers till n """
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r



def divs(n, start=1):
    """ returns a list of all divisors till n """
    divisors = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if n % i == 0:
            if n / i == i:
                divisors.append(i)
            else:
                divisors.extend([i, n // i])
    return divisors



def divn(n, primes):
    """ returns the number of divisors, two arguments n and the sieve till n """
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t



def lrfind(d, x, default=-1):
    """ Takes 2 arguments an iterable and an element. returns a tuple (firstoccurence,lastoccurence) -1 if not found """
    left = right = -1
    for i in range(len(d)):
        if d[i] == x:
            if left == -1: left = i
            right = i
    if left == -1:
        return default, default
    else:
        return left, right

def gcd(x, y): # math.gcd is slower
    """ returns greatest common divisor of x and y """
    while y:
        x, y = y, x % y
    return x

def ceil(n, k=1): return n // k + (n % k != 0) #returns math.ceil but protecting against floating inconsistencies
def input(): return sys.stdin.readline().strip()
def ii(): return int(input()) #inputs integer
def mi(): return map(int, input().split()) # inputting space seperated variables for example x,y,z
def li(): return list(map(int, input().split())) #inputting a space seperated list of integers
def lw(): return input().split() #inputting a space seperated list of strings
def lcm(a, b): return abs(a * b) // gcd(a, b) #returns LCM of two arguments
def prr(a, sep=' ', end='\n'): print(sep.join(map(str, a)), end=end) #For printing an iterable with seperator sep as optional second argument (default : " "), ending character (default: "\n") as optional third
def dd(): return defaultdict(int) #returns a dictionary with values defaulted to 0
def ddl(): return defaultdict(list) #returns a dictionary with values defaulted to []
def write(s): return sys.stdout.write(s)

###################################################################
def main():
    #CODE GOES HERE:
    n=ii()
    x=li()
    s=sum(x)/n
    s,t=int(s),ceil(s)
    answer0=sum([(i-s)*(i-s) for i in x])
    answer1=sum([(i-t)**2 for i in x])
    print(min(answer0,answer1))
""" -------- Python 2 and 3 footer by Pajenegod and c1729 ---------"""
 
py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange
 
import os, sys
from io import IOBase, BytesIO
 
BUFSIZE = 8192
 
class FastIO(BytesIO):
    newlines = 0
 
    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None
 
    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s
 
    def read(self):
        while self._fill(): pass
        return super(FastIO, self).read()
 
    def readline(self):
        while self.newlines == 0:
            s = self._fill();
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)
 
 
class IOWrapper(IOBase):
 
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode('ascii'))
            self.read = lambda: self.buffer.read().decode('ascii')
            self.readline = lambda: self.buffer.readline().decode('ascii')
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')
# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')
 
""" main function"""
 
if __name__ == '__main__':
    main()
    # threading.Thread(target=main).start()

Submission status: Wrong Answer

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

for i in range(max(X)):
    for j in range(n):
        tmp = abs(i - X[j])**2
        ans[i] += tmp

print(min(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
j = max(x)
m = 0

for p in range(j):
    c = 0
    z = 0
    for i in range(n):
        z = x[i] - p
        c = c + (z * z)
    
    if m == 0:
        m = c
    else:
        if m > c:
            m = c

print(m)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
m = 0
j = max(x)

for p in range(j):
    c = 0
    for i in range(n):
        p = (i+1) * (i+1) - n
        c = c + (p * p)
    
    if m == 0:
        m = c
    else:
        if m > c:
            m = c

print(c)

Submission status: Wrong Answer

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

x_max = 100
ans_min = 10000
for p in range(x_max):
    sum_ = 0
    for x in X:
        sum_ += (x - p) ** 2
    ans_min = min(sum_, ans_min)
print(ans_min)

Submission status: Wrong Answer

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

for i in range(n):
    p = (i+1) * (i+1) - n
    c = c + (p * p)

print(c)

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
N = int(input())
X = list(map(int,input().split()))
P = np.round(np.average(X))

print(np.dot(X,X) + P * P * N - 2 *np.sum(X)*P)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

L=min(X)
H=max(X)
smallest = 10**4
for p in range(L,H+1):
  sum=0
  #print(p)
  for j in range(N):
    sum=sum+(X[j]-p)**2
  #print(sum)
  if sum<=smallest:
    smallest=sum

print(smallest)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=list(map(int,input().split()))
res=10**6
for i in range(1,101):
  tmp = sum([(i-y)**2 for y in x])
  if res > tmp:
    res = tmp

Submission status: Wrong Answer

Solution code:
N = int(input())
X = sorted([int(i) for i in input().split()])
R = 100000
for c in range(X[0], X[-1]+1):
    if sum((c-X[i])**2 for i in range(N)) < R:
        R = sum((c-X[i])**2 for i in range(N))
    else:
        pass
print(R)

Submission status: Wrong Answer

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

ans = 10 ** 7
for i in range(1,MaxX):
    cost = 0
    for j in range(len(X)):
        cost += abs(X[j] - i) ** 2
    
    ans = min(ans, cost)

print(ans)

Submission status: Wrong Answer

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

cost = [0] * max(X)
for p in range(max(X)):
    for x in X:
        cost[p] += (x - p) ** 2

ans = min(cost)
print(ans)

Submission status: Wrong Answer

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

cost = [0] * max(X)
print(cost)
for p in range(max(X)):
    for x in X:
        cost[p] += (x - p) ** 2

ans = min(cost)
print(ans)

Submission status: Wrong Answer

Solution code:
n =int(input())
xi = list(map(int,input().split()))
min_kyo = 0
for house in xi:
  min_kyo += (1 -house)**2
  
for i in range(2,max(xi)):
  kyori = 0
  for house in xi:
    kyori += (i - house)**2
  if kyori < min_kyo:
    min_kyo = kyori
    
print(min_kyo)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=list(map(int,input().split()))
x.sort()
min = 10**15
su=0
for j in range(x[0],x[n-1]):
    for i in x:
        su=(i-j)**2+su  
    if min>su:
        min=su
    su = 0
print(min)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int,input().split()))
sigma = [0]*(X[-1]+1)
for p in range(X[-1]+1):
    for i in range(N):
        sigma[p] += (X[i]-p)**2
print(min(sigma))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
X = np.array([x for x in map(int,input().split())])

ans_candidate = int((X**2).sum()-(X.sum())**2/N)

if ((X-ans_candidate)**2).sum() < ((X-(ans_candidate+1))**2).sum():
    ans = ans_candidate
else:
    ans = ans_candidate+1

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
X = np.array([x for x in map(int,input().split())])

ans_candidate = int((X**2).sum()-(X.sum())**2/N)

if ((X-ans_candidate)**2).sum() < ((X-ans_candidate+1)**2).sum():
    ans = ans_candidate
else:
    ans = ans_candidate+1 

print(ans)

Submission status: Wrong Answer

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

p = sum(x)//n + 1

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

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
X=list(map(int,input().split()))
minhp=10001
for i in range(1,101):
    hp=0
    for hu in X:
        hp+=(hu-i)**2
    minhp=min(minhp,hp)
    
print(minhp)

Submission status: Wrong Answer

Solution code:
N=int(input())
X=list(map(int,input().split()))
minhp=10001
for i in range(1,101):
    hp=0
    for hu in X:
        hp+=(hu-i)**2
    minhp=min(minhp,hp)
    
print(minhp)

Submission status: Wrong Answer

Solution code:
import numpy as np
def IsDistributionBiased_Smaller (sortedarr,P):
    _ndarr=np.array(sortedarr)
    smallarr=np.where(_ndarr<=P)
    if len(smallarr) > len (sortedarr)//2:
        return True
    else:
        return False

def WorkloadCalculation(arr,P):
    D=0
    for a in range(len(arr)):
        d=abs(arr[a]-P)
        D += d**2
    return D

N=int(input())
Xlist=[]
X=input().split()
for x in X:
    _x=int(x)
    Xlist.append(_x)

Xlist.sort()
P=(Xlist[0]+Xlist[-1])//2

workload=10000000
STOPflg=False
    
if IsDistributionBiased_Smaller(Xlist,P) ==True:
    while STOPflg==False:
        _wl=WorkloadCalculation(Xlist,P)
        if _wl < workload:
            workload=_wl
            P+=1
        else:
            print(workload)
            STOPflg=True
            exit()
else:
    while STOPflg==False:
        _wl=WorkloadCalculation(Xlist,P)
        if _wl < workload:
            workload=_wl
            P-=1
        else:
            print(workload)
            STOPflg=True
            exit()
print(workload)

Submission status: Wrong Answer

Solution code:
import numpy as np
def IsDistributionBiased_Smaller (sortedarr,P):
    _ndarr=np.array(sortedarr)
    smallarr=np.where(_ndarr<=P)
    if len(smallarr) > len (sortedarr)//2:
        return True
    else:
        return False

def WorkloadCalculation(arr,P):
    D=0
    for a in range(len(arr)):
        d=abs(arr[a]-P)
        D += d**2
    return D

N=int(input())
Xlist=[]
X=input().split()
for x in X:
    _x=int(x)
    Xlist.append(_x)

Xlist.sort()
P=(Xlist[0]+Xlist[-1])//2

workload=10000000
STOPflg=False
    
if IsDistributionBiased_Smaller(Xlist,P) ==True:
    while STOPflg==False:
        print(P)
        _wl=WorkloadCalculation(Xlist,P)
        if _wl < workload:
            workload=_wl
            P+=1
        else:
            STOPflg=True
            exit()
else:
    while STOPflg==False:
        print(P)
        _wl=WorkloadCalculation(Xlist,P)
        if _wl < workload:
            workload=_wl
            P-=1
        else:
            STOPflg=True
            exit()
print(workload)

Submission status: Wrong Answer

Solution code:
n=int(input())
xlis = list(map(int,input().split()))
def tai(p,x):
  return pow(x-p,2)
ans=999999999999
for i in range(min(xlis),max(xlis)-min(xlis)+1):
  sum=0
  for j in xlis:
    sum+=tai(i,j)
  if ans>sum:
    ans=sum
    
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
xlis = list(map(int,input().split()))
def tai(p,x):
  return pow(x-p,2)
ans=999999999999
for i in range(min(xlis),max(xlis)-min(xlis)):
  sum=0
  for j in xlis:
    sum+=tai(i,j)
  if ans>sum:
    ans=sum
    
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
ans = 0

m = np.average(A)

x = round(m)

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

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int, input().split()))
X.sort()
Y = [0] * max(X)
for _x in X:
    for y_idx in range(len(Y)):
        Y[y_idx] += (_x - y_idx)**2
print(min(Y))

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int, input().split()))
X.sort()
a = -1
for i in range(X[0], X[-1]):
    b = 0
    for y in X:
        b += (y - i)**2
    if a == -1 or b < a:
        a = b
    elif a < b:
        break
print(a)

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
ar=np.array(list(map(int,input().split())))
m=np.inf

for i in range(min(ar),max(ar)):
    s=np.sum(np.square(ar-i))
    if s<m:
        m=s
print(m)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
X = list(map(int, input().split()))
P = int(math.ceil(sum(X) / N))
print(sum((x - P)**2 for x in X))

Submission status: Wrong Answer

Solution code:
from math import floor, ceil

N = int(input())

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

mean = int(ceil(sum(X)/N))

print(sum(map(lambda x: (x-mean)**2, X)))

Submission status: Wrong Answer

Solution code:
#整数の入力
N = int(input())

#スペース区切りの整数の入力リスト
X_list = list(map(int, input().split()))

ans_list = []



for i in range(N):
  ans = 0
  for j in range(N):
    ans = ans + (X_list[j]-(i+1))**2
    #print(j,"座標:",X_list[j],i+1,"番目 →",ans)
  ans_list.append(ans)
print(min(ans_list))

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int, input().split()))
start = min(X)
stop = max(X)
count = 0 
ans = 10**10
for i in range(start, stop+1):
    print(i)
    count = 0
    for x in X:
        count += (x-i)**2
    ans = min(count, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int, input().split()))
start = min(X)
stop = max(X)
count = 0 
ans = 10**9
for i in range(start, stop):
    count = 0
    for x in X:
        count += (x-i)**2
    ans = min(count, ans)
print(ans)

Submission status: Wrong Answer

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

y = sum(x) / n
ans1 = 0
ans2 = 0
ans3 = 0
if y == int(y):
  for i in x:
    ans1 = ans1 + (i-y)**2
  print(ans1)
elif y != int(y):
  y = int(y)
  z = int(y) + 1
  w = int(y) - 1
  for i in x:
    ans1 = ans1 + (i-y)**2
    ans2 = ans2 + (i-z)**2
    ans3 = ans3 + (i-w)**2
  print(min(ans1, ans2, ans3))

Submission status: Wrong Answer

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

y = sum(x) / n
ans = 0
for i in x:
  ans += (i-y)**2
print(int(ans)+1)

Submission status: Wrong Answer

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

y = sum(x) / n
ans1 = 0
ans2 = 0
if y == int(y):
  for i in x:
    ans1 = ans1 + (i-y)**2
  print(ans1)
elif y != int(y):
  y = int(y)
  z = int(y) + 1
  for i in x:
    ans1 = ans1 + (i-y)**2
    ans2 = ans2 + (i-z)**2
  print(min(ans1, ans2))

Submission status: Wrong Answer

Solution code:
n = int(input())
x =sorted(list(map(int, input().split())))
ans = 1000000
if n==1:
    ans = 0
else:
    for i in range(x[0],x[-1]):
        ttl = 0
        for j in x:
            ttl+=(j-i)**2
        ans = min(ans, ttl)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from decimal import Decimal, ROUND_HALF_UP
N = int(input())
X = [int(i) for i in input().split()]

ans = 0
X_mean = Decimal(str(sum(X) / N))
X_mean = X_mean.quantize(Decimal('0'), rounding=ROUND_HALF_UP)
print(X_mean)

for i in range(N):
    ans += (X[i] - X_mean) ** 2

print(ans)

Submission status: Wrong Answer

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

v_min = 10 ** 18
m = min( X )
M = max( X )
for i in range( m, M + 1):
  v = 0
  for x in X:
    x += ( i - x ) ** 2
  v_min = min( v, v_min )
print( v_min )

Submission status: Wrong Answer

Solution code:
from math import ceil, floor


def tai(X, p):
    return sum((X[i] - p) ** 2 for i in range(len(X)))


if __name__ == "__main__":
    N = int(input())
    X = [int(x) for x in input().split(" ")]
    mean_x = sum(X) / N
    if mean_x == int(mean_x):
        print(tai(X, mean_x))
    else:
        print(int(min(tai(X, ceil(mean_x)), tai(X, floor(mean_x)))))

Submission status: Wrong Answer

Solution code:
from math import ceil, floor


def tai(X, p):
    return sum((X[i] - p) ** 2 for i in range(len(X)))


if __name__ == "__main__":
    N = int(input())
    X = [int(x) for x in input().split(" ")]
    mean_x = sum(X) / N
    if mean_x == int(mean_x):
        print(tai(X, mean_x))
    else:
        print(min(tai(X, ceil(mean_x)), tai(X, floor(mean_x))))

Submission status: Wrong Answer

Solution code:
n=int(input())
x=list(map(int,input().split()))
x.sort()
ans=99999999999999999999
for i in range(x[0],x[n-1]):
  temp=i
  cal=0
  for j in range(0,n):
    cal=cal+(x[j]-temp)**2
  ans=min(ans,cal)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())

x=list(map(int,input().split()))
mx=max(x)
a=[]
cal=0

for i in range(mx):
    for j in range(len(x)):
        cal+=(x[j]-i)**2

    a.append(cal)
    cal=0


print(min(a))

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int, input().split()))
avg_X = sum(X) // len(X)
ans = 1e5

for P in range(max(0, avg_X-10), min(100, avg_X+10)):
    total = 0
    for position in X:
        total += (position - P) ** 2
    ans = min(ans, total)
    
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from statistics import mean

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

mean_X = mean(X)


print(int(sum([(x - mean_X)**2 for x in X]) + 1))

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ans = 999999999
for i in range(max(regis)):
    hp_sum = 0
    for regi in regis:
        hp_sum += (regi - i)**2
    ans = min(ans , hp_sum)

print(ans)

Submission status: Wrong Answer

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

print(sum([(xi-(sum(X)+N-1)//N)**2 for xi in X]))

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int,input().split()))
ans = 10**9
for i in range(max(X)):
    s = 0
    for j in X:
        s += (i-j)**2
    ans = min(ans,s)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
X = list(map(int, input().split()))
X.sort()
ans = 10**10
for p in range(X[0], X[-1]+1):
    tmp = 0
    for x in X:
        tmp += pow(x-p, 2)
    ans = min(ans, tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int, input().split()))
s = 0
for i in range(N):
  s = s + X[i]
  
P = s/N
import math
P = math.ceil(P)
ans = 0
for i in range(N):
  ans = ans + (X[i]-P)**2
  
print(ans)

Submission status: Wrong Answer

Solution code:

N = int(input())
X = list(map(int, input().split()))
mn = 10**9
for p in range(min(X), max(X)):
    c = 0
    for x in X:
        c += (p-x)**2
    mn = min(c, mn)
print(mn)

Submission status: Wrong Answer

Solution code:
N=int(input())
X=list(map(int, input().split()))
k1=(max(X)+min(X))//2
k2=k1+1
ans1=0
ans2=0
for x in X:
  ans1+=(k1-x)**2
  ans2+=(k2-x)**2

print(min(ans1, ans2))

Submission status: Wrong Answer

Solution code:
N=int(input())
X=list(map(int,input().split()))
total=1000000000
for i in range(X[0],X[-1]+1):
    tmp=0
    for j in X:
        tmp+=abs(j-i)**2
    total=min(total,tmp)
print(total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
x = input().split(' ')

p = 0
ans = []
while p <= int(x[n-1]):
  e = 0
  for i in range(n):
    e += (int(x[i])-p)**2
  ans.append(e)
  p+=1
print(min(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
x = input().split(' ')
print(x)

p = 0
ans = []
while p <= int(x[n-1]):
  e = 0
  for i in range(n):
    e += (int(x[i])-p)**2
  ans.append(e)
  p+=1
print(min(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int,input().split()))
ans = 1000000000000000
for i in range(1,101):
    hp=0
    for j in range(N):
        B = (X[j]-i) ** 2
        hp+=B
    print(hp)
    if ans > hp:
        ans=hp

print(ans)

Submission status: Wrong Answer

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

if N == 1:
    print(0)
else:
    if N % 2 == 0:
        m1 = X[len(X) // 2 - 1]
        m2 = X[len(X) // 2]
    else:
        m1 = X[len(X) // 2 - 1]
        m2 = X[len(X) // 2 + 1]

    min_e = 10 ** 9
    for m in range(m1, m2 + 1):
        e = sum([(x - m) ** 2 for x in X])
        min_e = min(min_e, e)
    print(min_e)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
ans = float('inf')
for s in range(min(x),max(x)):
    ans_pre = 0
    for i in x:
        ans_pre += (i-s)**2
    ans = min(ans,ans_pre)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int, input().split()))
index = 1
tem = 0

for p in range(1, max(X)):
    sum = 0
    for i in range(N):
        sum += (X[i] -  p) ** 2
    if p == 1:
        tem = sum
    elif sum < tem:
        tem = sum
        index = p

print(tem)

Submission status: Wrong Answer

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

ans = 100000

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

Submission status: Wrong Answer

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

p = sum(x) // len(x)

for i in x:
    h += (i - (p + 1))**2

print(h)

Submission status: Wrong Answer

Solution code:
import math


def inp():
    return(int(input()))


def invr():
    return(map(int, input().split()))


n = inp()
arr = invr()
arr = sorted(arr)
max = arr[n-1]
min = arr[0]

cost = 100000000000
print(cost)
for p in range(min, max+1):
    temp_cost = 0
    for xi in arr:
        temp_cost += (xi-p)**2
    if temp_cost < cost:
        cost = temp_cost
print(cost)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
ans=10e8
for j in range(l[0],l[-1]+1):
    hp=0
    for i in l:
        hp+=(i-j)**2
    if ans>hp:
        ans=hp
print(ans)

Submission status: Wrong Answer

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

#t = math.ceil(sum(x)/n)
t = sum(x)/n
ans = 0
for i in x:
  ans += abs((i-t))**2
print(math.ceil(ans))

Submission status: Wrong Answer

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

t = math.ceil(sum(x)/n)
ans = 0
for i in x:
  ans += abs((i-t))**2
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N = I()
X = LI()
max_x = max(X)
ans = INF
for i in range(1,max_x):
    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 = 100000
for i in range(0,101):
    s = 0
    for j in range(N):
        s+=(X[j]-i)**2
    ans = min(ans,s)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int, input().split()))
ans = 100000
for i in range(0,100):
    s = 0
    for j in range(N):
        s+=(X[j]-i)**2
    ans = min(ans,s)
print(ans)

Submission status: Wrong Answer

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

Xmax = max(X)
Xmin = min(X)

Pmin = 1000000
for i in range(Xmin, Xmax):
    p = 0
    for x in X:
        p += (x - i) ** 2
        
    Pmin = min(Pmin, p)

print(Pmin)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
x = list(map(int, input().split()))
 
t = 0
min = 0

for i in range(0,N):
     t = t +  x[i]/N

s = math.floor(t)
for i in range(0,N):
    min = min + (x[i] - s) **2

print(min)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
x = list(map(int, input().split()))
 
t = 0
min = 0

for i in range(0,N-1):
     t += x[i]/N

s = math.floor(t)
print(s)
for i in range(0,N-1):
    min += (x[i] - s) **2

print(min)

Submission status: Wrong Answer

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

s = float(x[0])
for i in range(N-1):
	s = (s + x[i+1]) / 2

min = math.floor(s)

print(min)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
S = sum(x)
Ave = sum(x) // n
m = 10**6
score = 0
count = 0

for p in range(Ave-100,Ave+101): 
    for i in range(n):
        score += (x[i]-p)**2
    if score < m:
        m = score
        score = 0
print(m)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
S = sum(x)
Ave = sum(x) // n
m = 10**6
score = 0
count = 0

for p in range(Ave-100,Ave+101): 
    for i in range(n):
        score += (x[i]-p)**2
    if score < m:
        m = score
        score = 0
print(m,p)