peterverebics/CodeNet_Python_118 huggingface dataset:
s = input().split() 
n = int(s[0])
k = int(s[1])

i = 0

while k ** i < n:
  i += 1

print(i)
N,K = map(int,input().split())

for i in range(2,N//K):
  if K**i>=N:
    print(i)
    exit();
n, k = [int(i) for i in input().split()]

for i in range(n):
  if n/k**i <= 1:
    print(i)
    break
N, M = map(int, input().split())
X = int(M)
ans = 1
while N > X:
  ans += 1
  X = X * M
print(ans)
n,p=map(int,input().split())
for i in range(10000):
  if p**i<=n<p**(i+1):
    print(i-1)
    exit()
import math

N, K = map(int,input().split())
print(math.ceil(math.log(N, K)))
strings = input().split(' ')
N = int(strings[0])
K = int(strings[1])
 
ans = 0
max = 1

while max < N:
  max = max * K
  ans  =ans + 1
  
print(ans)
n, k = map(int, input().split(' '))
cnt = 1
while True:
  q = int( n / k)
  if q < k:
    break
  else:
    n = q
  cnt += 1
print(cnt+1)
n,k=map(int,input().split());print(sum(n>k**i for i in range(100))+k>=n)
n,k = map(int, input().split())

isFlg = False
i=1
while True:
    tmp = k **i

    if n <= tmp:
        isFlg = True

    if isFlg:
        break

    i+=1


print(i)
n, k = map(int, input().split())
cnt = 0
while(True):
  n=n//k
  cnt+=1
  if n<k:
    print(cnt+1)
    exit()
a,b=map(int,input().split())
c=0
while a//b>=b:  
  a=a//b
  c+=1
print(c+2)
import math

line=list(map(int,input().split()))
a=line[0]
b=line[1]

n=math.log(a,b)
print(math.ceil(n))
N,K = map(int,input().split())
for i in range(N):
    if N >=2**i and N <2**(i+1):
        print(i+1)
        break
n,k = map(int, input().split())
res = 0
m = n-1
a = 1
while True:
    if k**(a-1) < n and n <= k**a:
        ans = a
        break
    a += 1
print(ans)
N, K = map(int, input().split())
ans = 1
now = K
while now < N:
    now *= K
    ans += 1

print(ans)
N,K = map(int,input().split())

i = 0
anslist = []
while True:
  i+=1
  anslist.append(N%K)
  N = N//K
  #print (N)
  if N<K:
    anslist.append(N)
    i+=1
    break
    
anslist.reverse()
#print (anslist)
#print (''.join(map(str, anslist)))
print (i)
n, k = map(int, input().split())
ans = []
while n > k :
  n = n // k
  mod = n % k
  ans.append(str(ans))
print("".join(ans))
n,k=list(map(int,input().split()))
import sys
ans=1
num=1
while(1):
  if num>=n:
    print(ans-1)
    sys.exit()
  num=num*k
  ans=ans+1
N, K = map(int, input().split())
ans = 0
now = 1
while now < N:
    now *= K
    ans += 1

print(ans)
n, k =list(map(int, input().split()))
l = []
while True:
    l.append(n % k)
    n = n // k
    if n == 0:
        l.append(n % k)
        break
ans = len(l)
print(ans)
def calculate_num(m, n):
  integer = m
  base = n
  result = ''
  while integer > 0:
    result += str(integer%base) + result
    integer = integer//base
    print(integer)
  return result

def main():
  num = input()
  num_list = num.split()
  number = int(num_list[0])
  base = int(num_list[1])
  result = calculate_num(number, base)
  print(int(result))
main()
n, k = map(int, input().split())
i = 1
while True:
    if n - k**i > 1:
        i+=1
        n -= k ** i
    else:
        i+=1
        break
print(i)
n,k = map(int, input().split())

for i in range(1,10):
  if n <= k ** i:
    print(i +1)
    break
def base10to(n, b):
  if (int(n/b)):
    return base10to(int(n/b), b) + str(n%b)
  return str(n%b)
N, K = map(int, input().split())
print(base10to(N, K))
import math
n, k = map(int, input().split())
print(math.ceil(math.log(n, k)) + 1)
N, K = map(int, input().split())
count = 0
while N > K:
    N = N / K
    count += 1
count += 1
print(count)
n, k = map(int, input().split())
count = 0
while True:
    n = int(n // k)
    count += 1
    if n < k:
        count += 1
        break
    else:
        continue
print(count)
n,k = map(str, input().split())
k = int(k)
num = 0

for i in range(0, len(n)):
  num += int(n[i]) * (len(n)-i) * k^(len(n)-i)
  
print(len(str(num)))
N, K = map(int,input().split())

for i in range(10**9):
    if K**i < N:
        i = i + 1
    else:
        ans = i
        print(ans)
        break
import math
n, k = map(int, input().split())
num = n
count = 1

while num  >= k:
    num = num // k

print(count)
import numpy as np
n,k= map(float,input().split())
dig = int(np.ceil(np.log(n)/np.log(k)))
if k**(dig-1) == n:
    dig = dig - 1
print(dig)
import math
n,k=map(int,input().split())
t=math.log(n,k)
if t==int(t):
    print(int(t))
else:
    print(int(t)+1)
def sinsu():
  N,K=map(int,input().split())
  S=1
  while N>=K:
    K=K*K
    S+=1
  print(S)
n,k = map(int, input().split())
ans = 0
c = 0
while n > k**c:
    c += 1
a = k-1
for i in range(1,c+1):
    for j in range(1,k+1):
        if (k-j)*k**(c-i)<=n:
            n -= (k-j)*k**(c-i)
            ans += (k-j)*10**(c-i)
            break
print(len(str(ans)))
n,k=map(int,input().split())
c=0
while k**c<n:
  c+=1
print(c)
N, K = map(int, input().split())
for i in range(1, 10000)[::-1]:
    if N // (K ** i) != 0:
        print(i + 1)
        break
# coding: utf-8
# Your code here!

n,k = map(int, input().split())
cnt = 1
a = k
while k < n:
  k = k*a
  cnt += 1

print(cnt)
from sys import stdin


def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out


def get_result(data):
    print(data)
    N, K = data[0]
    return len(Base_10_to_n(N, K))

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)
n,k=map(int,input().split())
i=0
while True:
  if n>k**i:
    i=i+1
  else:
    print(i)
    break
N,K=map(int,input().split())
J=K
ans=0

while N>J:
    J=J*K
    ans+=1

print(ans)
N,K = map(int,input().split())

if N ==0 or N==1:
    print(1)
    exit()

for i in range(1,10000,1):
    if K**i < N and N < K**(i+1) -1:
        print(i+1)
        exit()
N,K = map(int,input().split())
temp = N
for i in range(1,10**9):
    temp = int(temp/K)

    if temp < K:
        print(i+1)
        break
n , k = map(int,input().split())
count = 0
origk = k
while(True):
    if n <= k:
        print(1+count)
        break
    k *= origk
    count+=1
n, k = map(int, input().split())

d = 1

while True:
  if n > k ** d:
    d += 1
  else:
    print(d)
    exit()
N,K = map(int,input().split())
count = 0
while N>0:
  N=N//K
  count +=1
  print(count)
n, k = map(int, input().split())
ans = 0
while k ** ans < n:
    ans += 1
print(ans)
import sys

n,k = map(int,input().split())
if n == 1:
	print(1)
	sys.exit()
i = 0
num = 1
while True:
	if n <= num:
		break
	num *= k
	i += 1

print(i)
import math
n,k = map(int,input().split())
print(math.ceil(math.log(n,k)))
import sys
from io import StringIO
import unittest

def resolve():
    n,k = list(map(int,input().split()))

    c=1
    s=k
    while 1:
        if s>=n:
            print(c)
            return
        s*=k
        c+=1

    return

resolve()
N, K = map(int, input().split())
for i in range(1, 100)[::-1]:
    if N // (K ** i) != 0:
        print(i + 1)
        break
# スペース区切りの整数の入力
n, k = map(int, input().split())

ans=0
while k**ans<n:
  ans=ans+1
print(ans)
n,k = map(int,input().split())
i = 0

while k**i < n:
  i +=1
  
print(i)
# -*- coding: utf-8 -*-
from math import log, ceil

def solve():
    N, K = map(int, input().split())
    return str(ceil(log(N+1,K)))

if __name__ == '__main__':
    print(solve())
n, k = map(int, input().split())
count = 1

while 1:
    n = n // k
    count += 1 
    
    if n < k:
        break

print(count)
import math
N, R = list(map(int, input().split()))
print(math.ceil(math.log(N, R)))
import math

N,K = map(int,input().rstrip().split(" "))
print(math.ceil(math.log(N+1,K)))
n, k = map(int, input().split())
ans = 0
while n: # 一番下の桁を削る
  ans += 1
  n /= k
print(ans)
import math
a = list(map(int, input().split()))
print(math.ceil(math.log(a[0],a[1])))
import numpy as np

N, K = map(int,input().split())

max_base = [30, 22, 16, 14, 13, 12, 11, 10]
base = np.array([i for i in range(max_base[K-3])])

base = K**base
target = np.array([N]*max_base[K-3])

index = np.where(base <= target, 1, 0)

print(np.sum(index))
import os

def main():
    result_num = []
    a=[int(x) for x in input().split()]
    num,result = a[0],a[1]
    count = 0

    while(True):
        result_num.append(num%result)
        num = num//result
        count += 1
        if result > num:
            result_num.append(num)
            break

    print(count)

if __name__ == "__main__":
    main()
N, K = map(int, input().split())
ans = 0

while N>(K**ans):
    ans += 1

print(ans)
N, K = map(int, input().split())

for i in range(N+1):
    if K ** i >= N:
        print(max(i, 1))
        break
x = input().split()
N = int(x[0])
K = int(x[1])

d = 0

while K ** d < N:
  d +=1

print(d)
import math

inputs = [int(i) for i in input().split(" ")]

print(math.ceil(math.log(inputs[0], inputs[1])))
N, K = map(int, input().split())

count = 0
while N > K ** count:
    count += 1

print(count)
n, k = map(int,(input().split()))

i = 0
while n >= k**i:
    i = i+1
    n = n-k**i

print(i+1)
x = input().split()
N = int(x[0])
K = int(x[1])

if N ==1:
    print(1)
else:
    d = 0
    while K ** d < N:
        d +=1

    print(d)
N, K = map(int, input().split())

exp = 1
while True:
    if N <= K ** exp:
        print(exp)
        exit()
    exp += 1
from math import * 
N, K = list(map(int, input().split()))
print(ceil(log(N, K)))
import math
N, K = map(int,input().split())
M = ""
while True:
  M = str(N%K) + M
  N = N//K
  if N//K ==0:
    M = str(N) + M
    break

print(len(M))
n, k  =  map(int,input().split())

if n == 1:
    print(1)
else:
    a=1
    ans = 0
    while a<n:
        a *=k
        ans += 1

    print(ans)
import math
N,K=map(int,input().split())


print(math.ceil(math.log(N,K)))
N, K = list(map(int,input().split()))
ans = 1
while N > K:
    N //=K
    ans += 1
print(ans)
N,K = map(int,input().split())
digit=[]

while 1:
    digit.append(N%K)
    N = N//K
    if N < K:
        digit.append(N)
        break

print(len(digit))
N,K = map(int, input().split())
i = 1
while K**i < N:
    i+=1
else:
    print(i)
n,k = map(int,input().split())
for i in range(100000):
  if k**(i-1) < n <= k**i:
    print(i)
    break
n, k = map(int, input().split())
tmp = 0
for i in range(1, n):
    tmp += k**i
    if n <= tmp:
        print(i+1)
        break
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n,k=map(int,input().split())
print(math.ceil(math.log(n,k)))
N, K = map(int, input().split())

ans = 0

while(N > 1):
    N= N/K
    ans += 1
  
  
print(ans)
# coding: utf-8
import math

n,k = map(int, input().split())
print(int(-(-math.log(n,k)//1)))
n,k = map(int,input().split())
lists = []
while 1:
    ans = n % k
    lists.append(ans)
    n = n// k
    if n < k:
        lists.append(n)
        break
print(len(lists))
n, k = map(int, input().split())
cnt = 0
val = k
for i in range(n):
    val *= k
    cnt += 1
    #print(k)
    if val > n+1:
        break
    #print(cnt)
    #print(i)
print(cnt+1)
from math import log, ceil


N, K = [int(i) for i in input().split()]
print(ceil(log(N, K)))
from sys import stdin
import math

n, k = [int(x) for x in stdin.readline().rstrip().split()]

cnt = 1
if n < k:
    print(cnt)
    exit

kk = k
while n > kk:
    kk = kk * k
    cnt += 1


print(cnt)
import math


def answer(n: int, k: int) -> int:
    return math.ceil(math.log(n, k))


def main():
    n, k = map(int, input().split())
    print(answer(n, k))


if __name__ == '__main__':
    main()
N,K = map(int,input().split())
a = 1

while K**a<N:
  a+=1

print(a)
N, K = map(int, input().split())
cout = 0
for i in range(N):
    N = N//K
    cout += 1
    if N<K:
        break
print(cout)
import math
n,k = map(int,input().split())
print(-int(-math.log(n,k)//1))
from math import log, ceil
N, K = map(int, input().split())

num = log(N, K)
print(ceil(num))
import fractions
import collections
from collections import deque
import math
import itertools

N,K=map(int,input().split())
tmp=1

if(N==1):
    print(1)
    exit()

while(K**tmp<=N):
    tmp+=1
if(K**(tmp-1)==N):
    print(tmp-1)
else:
    print(tmp)
import math
n,r=list(map(int,input().split()))
ans=math.log(n+1,r)
ans=math.ceil(ans)
print(ans)
n,k = map(int,input().split())
for i in range(10 ** 9):
    if n < k:
        print(1)
        break
    elif n - k ** i < k:
        print(i)
        break
N,K=map(int,input().split())
hey=N
ans=1
while hey//K >= K:
    ans += 1
    hey = hey//K
print(ans)
import math

N, K = map(float, input().split())
tans = math.log(N, K)

ans = math.ceil(tans)
print(ans)
n, k = map(int, input().split())
x = n
ans = 1
for i in range(n):
    ans += 1
    x = x // k
    if x < k:
        break

print(ans)
N, K = map(int, input().split())
ans = 0
while N > K-1:
    ans += 1
    N //= K
    print(N)
print(ans+1)
N,K=map(int,input().split())
i=1
while True:
    A=K**i
    if A<N:
        i=i+1
    else:
        print(i)
        break
# problem B
N, K = input().split()
n = int(N)
k = int(K)

ans = 0

for i in range(0,31):
    x = k**i
    if n <= x:
        print(ans)
        break
    else:
        ans += 1
N,K=input().split()
C=0
while(int(N)>=int(K)):
  C=C+1
  N=int(N)-int(K)**C
print(C)
n,k = map(int,input().split())
#nをk進数で表す
pri_ans = k
ans = 1
while pri_ans < n:
    pri_ans *= k
    ans += 1
print(ans)
n,k=map(int,input().split())
i=0
while k**i<n:
  i+=1
print(i)
# coding: utf-8
# Your code here!
N,K=map(int,input().split())

temp=1
ans=0
while N>temp:
    temp*=K
    ans+=1

print(ans)
n,k=map(int,input().split())
if n<k:
  print(1)
  exit()
for i in range (1000):
  if k**i==n:
    print(i)
    exit()
  elif k**i < n <k**(i+1):
    print(i+1)
    exit()
n, k = map(int,input().split())
count = 0
while True:
  n = n//k
  count += 1
  print(n)
  if n <1:
    print(n)
    break
    
    
print(count)
n, k = map(int, input().split())
counter = 1
while not n <= 1:
    n = int(n / k)
    counter += 1
print(counter)
import math

N, K = map(int, input().split())
print(math.ceil(math.log(N+1, K)))
n, p = [int(x) for x in input().split()]
count = 1
while p < n:
    n = n/p
    count += 1
print(count)
import math
from decimal import *

N, K = map(int, input().split())
ans = math.ceil(Decimal(math.log(Decimal(N), Decimal(K))))

print(ans)
n,k=map(int,input().split())
res=0
while(n>k):
    #print(n)
    n/=k
    res+=1
print(res+1)
n, k = map(int, input().split())
counter = 1
while n > k:
    n = int(n / k)
    counter += 1
    print(n)
print(counter)
from math import log, ceil
N, K = map(int, input().split())
print(ceil(log(N, K)))
n = int(input())
x = list(map(int, input().split()))

max_x = max(x)
min_x = min(x)

ans = []
for i in range(1, 101):
  a = 0
  for xi in x:
    a += (xi - i)*(xi - i)
  ans.append(a)
  
print(min(ans))
n = int(input())
x = list(map(int, input().split()))
ans = float('inf')
energy = []

for i in range(1, 101):
    for j in x:
        energy.append((j - i) ** 2)
    sum_energy = sum(energy)
    if sum_energy < ans:
        ans = sum_energy
    energy = []

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

ans1=0
for i in x:
    ans1+=(i-average-1)**2

print(min(ans,ans1))
n=int(input())
x=list(map(int, input().split()))
a=min(x);b=max(x)+1
ans=[]
for i in range(a,b):
    res=0
    for j in range(n):
        res+= (i-x[j])**2
    ans+=[res]
print(min(ans))
from sys import stdin

n = int(stdin.readline().strip())
x_lst = [int(x) for x in stdin.readline().strip().split()]

p1 = sum(x_lst) // n
p2 = sum(x_lst) // n + 1

p1_sum = sum([(x-p1) ** 2 for x in x_lst])
p2_sum = sum([(x-p2) ** 2 for x in x_lst])

print(min(p1_sum, p2_sum))
def main():
    n=int(input())
    x=list(map(int,input().split()))
    ans = [0] * 100
    m=10**8
    for i in range(1,101):
        for j,aa in enumerate(x):
            ans[i-1] += (aa-i)**2
        m=min(m,ans[i-1])
    print(m)
if __name__=='__main__':
    main()
n = int(input())
*l, = map(int,input().split())
suml = sum(l)
suml2 = sum([i**2 for i in l])
ave1 = suml//n 
ave2 = -(-suml//n)
ans1 = suml2 - 2*suml*ave1 + n*ave1*ave1
ans2 = suml2 - 2*suml*ave2 + n*ave2*ave2
print(min([ans1,ans2]))
N = int(input())
x = list(map(int, input().split()))
hp_list = [sum([(xx-p)**2 for xx in x]) for p in range(min(x), max(x)+1)]
print(min(hp_list))
N = int(input())
X = list(map(int,input().split()))
min = 1000000
for i in range(101):
    d = 0
    for j in range(N):
        d += (i-X[j])**2
    if min > d:
        min = d
print(min)
n=int(input())
a=list(map(int,input().split()))
m=int(sum(a)/n+0.5)
print(sum((i-m)**2 for i in a))
n = int(input())
x = list(map(int, input().split()))
if max(x)-min(x)==0:
    print(0)
else:
    k=max(x)-min(x)
    box=[0]*k

    for i in range(0,k):
        aa=0
        for j in range(0,n):
           aa = aa+(x[j]-min(x)-i)**2
        box[i]=aa


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

ans = 10 ** 9

x_min = min(x)
x_max = max(x)

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

print(ans)
n = int(input())
x = list(map(int, input().split()))
sum1 = 100*100**2
for i in range(101):
    sum2 = 0
    for j in range(len(x)):
        sum2 += (x[j] - i)**2
    if sum2 < sum1:
        sum1 = sum2
print(sum1)
N = int(input())
l_x = list(map(int, input().split()))
d_min = 999999999999999
left = min(l_x)
right = max(l_x)
for p in range(left, right + 1):
  total = 0
  for x in l_x:
    total += (p - x) ** 2
  if total < d_min:
    d_min = total

print(d_min)
# coding:utf-8

N = int(input())
X = [el for el in map(int, input().split(' '))]
ans = 2 ** 63 - 1

for point in range(100):
    tmp = 0
    for x in X:
        tmp += (x - point) ** 2
    if ans > tmp:
        ans = tmp

print(ans)
n = int(input())
x = sorted(list(map(int,input().split())))
li = []
cost = 0
for i in range(x[0],x[-1]+1,1):
    cost = 0
    for b in x:
        cost += (b-i)**2
    li.append(cost)
print(min(li))
N = int(input())
X = list(map(int,input().split()))

Physical_strength = 0
flag = 0
n=0
while 1:
    n += 1
    flag=0
    for Xi in X:
        flag += (Xi-n)**2
    if n == 1:
        Physical_strength = flag
    if Physical_strength > flag:
        Physical_strength = flag
    elif Physical_strength < flag and n > N:
        break

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

syukai = sum(x)//n
ans=0
ans1=0
ans2=0
for i in range(n):
    ans += pow(x[i]-syukai-1,2)
    ans1 += pow(x[i]-syukai,2)
    ans2 += pow(x[i]-syukai+1,2)
print(min(ans,ans1,ans2))
import math
N = int(input())
X = list(map(int,input().split()))
mean = round(sum(X)/N)
var = sum([(x - mean) ** 2 for x in X])
print(var)
N = int(input())
X = list(map(int,input().split()))
X.sort()
m=10**18
for p in range(102):
    s=0
    for i in range(N):
       s+= (X[i]-p)**2
    if(m>s): m=s
print(m)
N = int(input())
X = list(map(int, input().split()))
P = sum(X)//N
ans1 = 0
ans2 = 0
for x in X:
    ans1 += (P-x)**2
    ans2 += (P+1-x)**2
print(min(ans1, ans2))
n = int(input())
x = list(map(int, input().split()))
x.sort()
ans = 10**9+7
for i in range(x[0], x[n-1]+1):
    res = []
    for j in range(n):
        res.append((i-x[j])**2)
    ans = min(sum(res), ans)
print(ans)
n = int(input())
zyusyo = list(map(int, input().split(" ")))

min_zyusho = min(zyusyo)
max_zyusyo = max(zyusyo)

ans = 10**9
for p in range(min_zyusho, max_zyusyo+1):
    sum = 0
    for z in zyusyo:
        sum += (z-p)**2
    if sum < ans:
        ans = sum

print(ans)
import math
def main():
  N=int(input())
  X=list(map(int,input().split()))
  x_mean=round(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()
N= int(input())
X = list(map(int,input().split()))
def calc(n):
  ans = 0
  for x in X:
    ans += (x-n)**2
  return ans
ans = 100000000
for n in range(100):
  ans = min(ans,calc(n))
print(ans)
n = int(input())
x = list(map(int, input().split()))

ave = sum(x)/n
p = round(ave)
res = 0
for i in x:
  res += (i -p )**2
print(res)
number = int(input())
coordinates = list(map(int, input().split()))
coordinates.sort()
coordinates.reverse()
#print(coordinates)
list = []
for i in range(coordinates[0]+1):
    total=0
    for j in range(number):
        total += (coordinates[j]-i)**2
    list.insert(0, total)
list.sort()
print(list[0])
import numpy as np
import math
N = int(input())
X_k = list(map(int , input().split(" ")))

P = float(sum(X_k)/N)
P_ceil = int(math.ceil(P))
P_floor= int(math.floor(P))

ceil_sum = 0
floor_sum = 0

for X in X_k:
    ceil_sum = ceil_sum + (P_ceil-X)*(P_ceil-X)
    floor_sum = floor_sum + (P_floor-X)*(P_floor-X)


if (ceil_sum-floor_sum > 0):
    print(floor_sum)
else:
    print(ceil_sum)
n = int(input())
xn = [int(num) for num in input().split()]

answer = []
for n in range(1,max(xn)+1):
  sum = 0
  for x in xn:
    sum += (x-n)**2
  answer.append(sum)

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

minX = min(X)
maxX = max(X)
if minX==maxX:
    print(0)
    quit()

HP = []
for p in range(minX, maxX):
    hp = 0
    for x in X:
        hp += (x-p)**2
    HP.append(hp)

print(min(HP))
N = int(input())
L = list(map(int,input().split()))
P = round(sum(L) / N)
A = []
for i in L:
  x = (i - P)*(i-P)
  A.append(x)
print(sum(A))
import sys
N = int(input())
X = [int(_) for _ in input().split()]
ans_list = []
if N == 1:
    print('0')
    sys.exit()
for i in range(min(X), max(X) + 1):
    ans = 0
    for j in X:
        ans += (j - i) ** 2
    ans_list.append(ans)

print(min(ans_list))
N=int(input())
X=input().split()

X=[int(n) for n in X]

S=0
for x in X:
    S+=x

P=round(S/N)

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

print(V)
import math
N=int(input())
X=list(map(int,input().split()))
Prange= range(math.floor(min(X))-1,math.ceil(max(X))+1)
summin=100000000000
for P in Prange:
    sum=0
    for x in X:
        sum+=(P-x)**2
    if summin > sum:
        summin=sum
print(summin)
N=int(input())
S=list(map(int,input().split()))

select=len(S)
goukei=10**10
for i in range(1,100):
    kouho=0
    for j in range(select):
        kouho+=(S[j]-i)**2
    
    if kouho<goukei:
        goukei=kouho
    
print(goukei)
import math
n = int(input())
x = list(map(int, input().split()))
y = round((2*sum(x))/(2*n))
ans = 0
for i in range(n):
  ans += (y-x[i])**2
print(ans)
N = int(input())
X = list(map(int, input().split()))

sum_list = []
for p in range(min(X), max(X)+1):
    _sum = 0
    for x in X:
        _sum += abs(p-x) ** 2

    sum_list += [_sum]

print(min(sum_list))
n = list(map(int, input().split()))[0]
x = list(map(int, input().split()))
m = 1000000009
for i in range(100):
    sum = 0
    for j in range(len(x)):
        sum += (i - x[j]) ** 2
    m = min([m, sum])
print(m)
import math

N=int(input())

inputs=input().split(" ")
X=[]

mini=100
maxi=0


for i in inputs:
    i=int(i)
    X.append(i)

    if int(i)<mini:
        mini=i

    if int(i)>maxi:
        maxi=i

minpowersum=math.pow(10,9)
for P in range(mini,maxi+1):

    powersum=0
    for j in range(N):
        powersum+=math.pow((X[j]-P),2)

    if powersum<minpowersum:
        minpowersum=powersum


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

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

m = sum(X) // N
print(min(cost(m), cost(m+1)))
n=int(input())
li = list(map(int,input().split()))
ans=[]
i=1
while i<=101:
	for j in range(n):
		cost=[(li[j]-i)**2 for j in range(n)]
		ans.append(sum(cost))
	i+=1
print(min(ans))
N = int(input())
X = list(map(int, input().split()))

mm = 0
for x in X:
    mm += x**2

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

    if s < mm:
        mm = s

print(mm)
import numpy as np
N = int(input())
X = np.array(list(map(int,input().split(" "))))

energy = np.sum((X - X[0])**2)

X_max,X_min = np.max(X),np.min(X)
for i in range(X_min,X_max):
    energy_sum = np.sum((X-i)**2)
    if energy > energy_sum:
        energy = energy_sum

print(energy)