CodeEff/ECCO huggingface dataset:
# Original solution
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(eval(input()))
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return list(map(list, list(zip(*read_all))))

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

N = I()
a = LI()

asort = sorted(a)

d = defaultdict(int)
for i in range(N):
    d[a[i]] += 1

ans = [0]*N
max_ = 0
for i in range(N):
    if a[i] > max_:
        diff = a[i]-max_
        num = N-bisect_left(asort,a[i])
        ans[i] = num*diff
        for j in range(max_+1,a[i]):
            ans[i] += (j-max_)*d[j]
        max_ = a[i]

ans[0] = sum(a)-sum(ans[1:])

for i in range(N):
    print((ans[i]))

# Optimized solution
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(eval(input()))
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return list(map(list, list(zip(*read_all))))

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

N = I()
a = LI()

asort = sorted(a)

d = defaultdict(int)
for i in range(N):
    d[a[i]] += 1
keys = sorted(list(d.keys()))

ans = [0]*N
max_ = 0
place = 0
for i in range(N):
    if a[i] > max_:
        diff = a[i]-max_
        num = N-bisect_left(asort,a[i])
        ans[i] = num*diff
        for j in range(place,len(keys)):
            if keys[j] <= max_:
                continue
            elif keys[j] >= a[i]:
                place = j
                break
            else:
                ans[i] += (keys[j]-max_)*d[keys[j]]
        max_ = a[i]

ans[0] = sum(a)-sum(ans[1:])

for i in range(N):
    print((ans[i]))
# Original solution
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return list(map(int,input().split()))
def I():
    return int(eval(input()))
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

n=I()
a=LI()

d={}
nd={}
for i,x in enumerate(a):
    if x in d:
        d[x]=min(i,d[x])
        nd[x]+=1
    else:
        d[x]=i
        nd[x]=1

A=[i for i in list(d.items())]
A=sorted(A,key=lambda x:x[0])
#[::-1]
ans=[0]*n
px,pm=A.pop()
nn=nd[px]
while A:
    x,m=A.pop()
    ans[pm]+=(px-x)*nn
    nn+=nd[x]
    px,pm=x,min(m,pm)
ans[0]+=sum(a)-sum(ans)
#print(n,sum(a),a)
#print(*ans)
for i in ans:print(i)
    

# Optimized solution
def I():
    return int(eval(input()))
def LI():
    return [int(i) for i in input().split()]

n=I()
a=LI()

d={}
nd={}
for i,x in enumerate(a):
    if x in d:
        d[x]=min(i,d[x])
        nd[x]+=1
    else:
        d[x]=i
        nd[x]=1

A=sorted([i for i in list(d.items())],key=lambda x:x[0])
ans=[0]*n
px,pm=A.pop()
nn=nd[px]
while A:
    x,m=A.pop()
    ans[pm]+=(px-x)*nn
    nn+=nd[x]
    px,pm=x,min(m,pm)
ans[0]+=sum(a)-sum(ans)
for i in ans:
    print(i)
# Original solution
# -*- coding:utf-8 -*-
n = int(input())
a = [[int(k),i+1] for i,k in enumerate(input().split())]
a.sort(reverse=True)
z = [l[1] for l in a]
s=[0]*n
a.append([0,0])
for i,p in enumerate(a[:-1]):
    if not p[0] == a[i+1][0]:
        q = p[0] - a[i+1][0]
        y = z[:i+1]
        s[min(y)-1] += (i+1)*q

for t in s:
    print(t)

# Optimized solution
# -*- coding:utf-8 -*-
n = int(input())
a = [[int(k),i+1] for i,k in enumerate(input().split())]
a.sort(reverse=True)
z = [l[1] for l in a]
s=[0]*n
a.append([0,0])
min_a_i = float('inf')
for i,p in enumerate(a[:-1]):
    min_a_i = min(min_a_i, a[i][1])
    if not p[0] == a[i+1][0]:
        q = p[0] - a[i+1][0]
        s[min_a_i-1] += (i+1)*q

for t in s:
    print(t)
# Original solution
import collections
import heapq
n=int(eval(input()))
A=[int(i) for i in input().split()]
Ans=[0]*n
M=[0]
for i in range(n):
  M.append(max(M[-1],A[i]))
D=collections.defaultdict(int)
H=[]
for i in range(n):
  j=n-1-i
  if A[j]<=M[j]:
    heapq.heappush(H,-A[j])
  else:
    Ans[j]=(A[j]-M[j])*(D[A[j]]+1)
    D[M[j]]+=D[A[j]]+1
    ct=0
    while H:
      a=heapq.heappop(H)
      a=-a
      if a<=M[j]:
        heapq.heappush(H,-a)
        break
      else:
        Ans[j]+=a-M[j]
        D[M[j]]+=1

for a in Ans:
  print(a)


# Optimized solution
import collections
import heapq
n=int(eval(input()))
A=[int(i) for i in input().split()]
Ans=[0]*n
M=[0]#自分より前の最大値をメモ。これ以下だと現れない
for i in range(n):
  M.append(max(M[-1],A[i]))
D=collections.defaultdict(int)
H=[]
for i in range(n):
  j=n-1-i
  if A[j]<=M[j]:
    heapq.heappush(H,-A[j])#出現しないインデックスの数を管理。大きいほうから取り出す。
  else:
    Ans[j]=(A[j]-M[j])*(D[A[j]]+1)#自分より前の最大値と自分の差かける自分自身と同じ数のこれまでの出現回数
    D[M[j]]+=D[A[j]]+1#自分自身より後ろの自分と同じ数全てを自分より前の最大値まで減らすことで増える分
    ct=0
    while H:#自分より後ろで自分より小さいが、自分の前の最大値より大きいものを全て見る
      a=heapq.heappop(H)
      a=-a
      if a<=M[j]:
        heapq.heappush(H,-a)
        break
      else:
        Ans[j]+=a-M[j]
        D[M[j]]+=1

for a in Ans:
  print(a)
# Original solution
n,x=list(map(int,input().split()))
line=list(map(int,input().split()))
Sum=[0]
sum=0
for i in range(n):
  sum+=line.pop()
  Sum.append(sum)
Ans=10**18
for k in range(1,n):
  p=0
  for i in range(n+k-1//k):
    if i==0:
      if n>=k:
        p+= (Sum[k])*5
      else:
        p+=(Sum[n])*5
        break
    else:
      if n> (k*i +k):
        p+= (Sum[k*i +k]-Sum[k*(i-1) +k])*(2*i +3)
      else:
        p+= (Sum[n]-Sum[k*(i-1) +k])*(2*i +3)
        break
  ans=(n+k)*x + p
  Ans=min(Ans,ans)
print(Ans)

# Optimized solution
#入力
n,x=list(map(int,input().split()))
line=list(map(int,input().split()))
#累積和を計算しておく
#はじめに0を入れておくと、右からi番目で計算できる(i-1としなくて良い)
Sum=[0]
sum=0
#lineの後ろから値を取って、sumに足してlistに入れる
for i in range(n):
  sum+=line.pop()
  Sum.append(sum)
#大きい数で初期化(今回は小さい数の方が選ばれるので、十分大きい数で)
Ans=10**18
#それぞれのkについてコストを計算
for k in range(1,n):
  #pは純粋な移動のみのコスト
  p=0
  #kで割り切れる時は、n//k -1個のグループが出来る(最初は2kでグループを作る)
  #kで割り切れない時は、n//k 個のグループが出来る
  #よってn-1しておけばkで割り切れる時だけ-1出来る
  for i in range((n-1)//k):
    #はじめだけ処理が異なる
    if i==0:
      if n>=2*k:
        p+= (Sum[2*k])*5
      #2kの長さがなければ最初から最後まで足して終わり
      else:
        p+=(Sum[n])*5
        break
    else:
      if n> (k*i +2*k):
        #(i+1)*k+1から(i+2)*kまでの座標の和に移動コストをかける
        p+= (Sum[k*i +2*k]-Sum[k*(i-1) +2*k])*(2*i +5)
      else:
        p+= (Sum[n]-Sum[k*(i-1) +2*k])*(2*i +5)
        break
  #n*xが1)のコスト、k*xが2)のコスト
  ans=(n+k)*x + p
  #小さい方をAnsに代入
  Ans=min(Ans,ans)
#答え
print(Ans)
# Original solution
N, X = list(map(int, input().split()))
X_l = list(map(int, input().split()))

def golden_search(func, l,r):
  # 最小値を求める
  phi = 1.618 # phi=2とすると三分探索
  if l >= r-4:
    return min([func(k) for k in range(l,r+1)])

  c1 = int((phi/(1+phi))*l + (1/(1+phi))*r)
  c2 = int((1/(1+phi))*l + (phi/(1+phi))*r)
  if func(c1) < func(c2):
    r = c2
  elif func(c1) >= func(c2):
    l = c1
  return golden_search(func, l,r)

def Ktimes(k):
  ret = X*k + X*N
  for i,x in enumerate(X_l[::-1]):
    t = i//k
    if t==0:
      ret += 5*x
    else:
      ret += ((t+2)**2 - (t+1)**2)*x
  return ret

answer = golden_search(Ktimes, 1, N)
print(answer)

# Optimized solution
N, X = list(map(int, input().split()))
X_l = list(map(int, input().split()))

def golden_search(func, l,r):
  # 最小値を求める
  phi = 1.618 # phi=2とすると三分探索
  if l >= r-4:
    return min([func(k) for k in range(l,r+1)])

  c1 = int((phi/(1+phi))*l + (1/(1+phi))*r)
  c2 = int((1/(1+phi))*l + (phi/(1+phi))*r)
  if func(c1) < func(c2):
    r = c2
  elif func(c1) >= func(c2):
    l = c1
  return golden_search(func, l,r)

memo = {}
def Ktimes(k):
  if k not in memo:
    memo[k] = X*k + X*N
    memo[k] += 2* sum(X_l[::-1][:k])
    memo[k] += sum([(2*(i//k)+3)*x for i,x in enumerate(X_l[::-1])])
  return memo[k]

answer = golden_search(Ktimes, 1, N)
print(answer)
# Original solution
N, X = list(map(int, input().split()))
A = list(map(int, input().split()))

ans = 1e15

"""
abcdef
f +4(f-e) + 9+(e-d) + 16(d-c) + ...
= 5f + 5e + 7d + 9c + 11b + 13a
"""
mul = [5] + [5 + 2*i for i in range(N)]
#print(mul)

for k in range(1,N+1): # Number of robots (this loop will be ended early)
  cost = N*X + k*X # pickup and throw costs(fixed with k)
  for i in range(1,N+1):
    cost += A[N-i] * mul[(i-1)//k]
  #print(k,cost)
  ans = min(ans,cost)
  if N//k <= 1: # early stopping (after mul is 5 for all A's, cost is monotonicaly increasing)
    print(ans)
    exit(0)
    
#print(ans)
  
  

# Optimized solution
N, X = list(map(int, input().split()))
A = list(map(int, input().split()))

ans = 1e19

"""
abcdef
f +4(f-e) + 9+(e-d) + 16(d-c) + ...
= 5f + 5e + 7d + 9c + 11b + 13a
"""
mul = [5] + [5 + 2*i for i in range(N)]
#print(mul)

CX = [0] * (N+1)

#cum_sum
for i in range(N):
  CX[i+1] = CX[i] + A[i]
  
for k in range(1,N+1): # Number of robots (this loop will be ended early)
  cost = N*X + k*X # pickup and throw costs(fixed with k)
  
  # partial point answer (not using cumulative sum)
  # for i in range(1,N+1):
  #  cost += A[N-i] * mul[(i-1)//k]
  ix = N
  loopc = 0
  while ix > 0:
    if ix-k > 0:
      cost += (CX[ix] - CX[ix-k]) * mul[loopc]
    else:
      cost += (CX[ix]) * mul[loopc]
    loopc += 1
    ix -= k
  
  #print(k,cost)
  ans = min(ans,cost)
  if N//k <= 1: # early stopping (after mul is 5 for all A's, cost is monotonicaly increasing)
    print(ans)
    exit(0)
    
#print(ans)
# Original solution

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

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


ans = 10**100

for k in range(1,N+1):
    cur = (N+k) * X
    dp = []
    dpnum = []

    for i in range(1,N+1,k):
        sum = 0
        num = 0
        for j in range(i,min(i+k,N+1)):
            sum += a[N-j]
            num += 1
        dp.append(sum)
        dpnum.append(num)


    count = 0
    for i in range(len(dp)):
        if i == 0:
            cur += dp[i] * 5
        else:
            cur += dp[i] * (2*(i+1) + 1)

    """
    for i in range(1,N+1,k):

        num = min(i+k-1,N) - i + 1

        if count == 0:
            cur += dp[count] * 5 * num
        else:
            cur += dp[count] * (2*(count+1) + 1) * num

        
        count += 1
    """
        
    ### print(dp, dpnum, cur)
    ans = min(ans, cur)

print(ans)



# Optimized solution

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

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

a = a[::-1]

dp = [0 for i in range(N+1)]
for i in range(1,N+1):
    dp[i] = a[i-1] + dp[i-1]

ans = 10**100

for k in range(1,N+1):
    cur = (N+k) * X


    count = 1
    i = k
    while 1:
        first = i - k
        last = min(N,i)
        flag = False
        if i > N:
            flag = True

        if count == 1:
            cur += dp[last] * 5
        else:
            cur += (dp[last] - dp[first]) * (2*count + 1)

        count += 1
        i += k
        
        if flag:
            break


        
    ### print(dp, cur)
    ans = min(ans, cur)

print(ans)
# Original solution
# coding:utf-8


INF = float('inf')


def inpl(): return list(map(int, input().split()))


N, X = inpl()
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)

ans = INF
for k in range(1, N + 1):
    tmp = 0
    i = 0
    cur = N - k
    while True:
        e = 5 if i == 0 else 2 * i + 3
        tmp += e * (B[cur + k] - B[max(cur, 0)])
        if cur <= 0:
            break
        i += 1
        cur -= k

    ans = min(ans, tmp + (N + k) * X)

print(ans)

# Optimized solution
# coding:utf-8


INF = float('inf')


def inpl(): return list(map(int, input().split()))


N, X = inpl()
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)

ans = INF
for k in range(1, N + 1):
    e = 5
    cur = N - k
    tmp = e * (B[N] - B[cur]) + (N + k) * X
    cur -= k
    while True:
        tmp += e * (B[cur + k] - B[max(cur, 0)])
        if cur <= 0:
            break
        e += 2
        cur -= k

    ans = min(ans, tmp)

print(ans)
# Original solution
# coding:utf-8


INF = float('inf')


def inpl(): return list(map(int, input().split()))


N, X = inpl()
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)

ans = []
for k in range(1, N + 1):
    e = 5
    cur = N - k
    tmp = e * (B[N] - B[cur]) + (N + k) * X
    cur -= k
    while True:
        tmp += e * (B[cur + k] - B[max(cur, 0)])
        if cur <= 0:
            break
        e += 2
        cur -= k

    ans.append(tmp)

print((min(ans)))

# Optimized solution
# coding:utf-8


INF = float('inf')


def inpl(): return list(map(int, input().split()))


N, X = inpl()
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)

ans = INF
for k in range(1, N + 1):
    tmp = 5 * B[N] + (N + k) * X
    cur = N - 2 * k
    while cur > 0:
        tmp += 2 * B[cur]
        cur -= k
    ans = min(ans, tmp)
print(ans)
# Original solution
N,X=list(map(int,input().split()))
x=list(map(int,input().split()))
w=[x[-1]]
for y in x[N-2::-1]:w+=[w[-1]+y]
r=1e20
for k in range(1,N+1):
    s=0
    for j in range(1,1+((N+k-1)//k)):
        s+=max(5,2*j+1)*(w[min(N,k*j)-1]-(0 if j==1 else w[k*j-k-1]))
    s+=(N+k)*X
    r=min(s,r)
print(r)

# Optimized solution
N,X=list(map(int,input().split()))
w=[0]
for i in map(int,input().split()):w+=[w[-1]+i]
print((min(5*w[N]+k*X+sum(2*w[j]for j in range(N-k*2,0,-k))for k in range(1,N+1))+N*X))
# Original solution

iN ,iX  = [int(x) for x in input().split()]
aX = [int(x) for x in input().split()]

#人のをみてようやく仕組みがわかったがこれで通るんだろうか

aCum = [0]*(iN)
aCum[0] = aX[0]
for i in range(1,iN):
    aCum[i]=aCum[i-1]+aX[i]

def fCalcCost(iN,iX,aCum,iK):
    iCost = 5 * aCum[-1]
    i = 2
    while  i*iK < iN  :
        iCost += 2 * aCum[-1 * i * iK -1]
        i += 1
    iCost += (iK +iN)*iX
    return iCost

iTotalCost = fCalcCost(iN,iX,aCum,1)
for iK in range(2,iN//2 + 2):
    iTotalCost = min(iTotalCost,fCalcCost(iN,iX,aCum,iK))
print(iTotalCost)


# Optimized solution

iN ,iX  = [int(x) for x in input().split()]
aX = [int(x) for x in input().split()]

aCum = [0]*(iN)
aCum[0] = aX[0]
for i in range(1,iN):
    aCum[i]=aCum[i-1]+aX[i]
def fCeil(iT,iR):
    return -1 * iT // iR * -1

def fCalcCost(iN,iX,aCum,iK):
    iCost = 5 * aCum[-1]
    for i in range(2,fCeil(iN,iK) ):
        iCost += 2 * aCum[-1 * i * iK -1]
#   i = 2
#   while  i*iK < iN  :
#       iCost += 2 * aCum[-1 * i * iK -1]
#       i += 1
    iCost += (iK +iN)*iX
    return iCost

iTotalCost = fCalcCost(iN,iX,aCum,1)
for iK in range(2,iN//2 + 2):
    iTotalCost = min(iTotalCost,fCalcCost(iN,iX,aCum,iK))
print(iTotalCost)
# Original solution
iN ,iX  = [int(x) for x in input().split()]

aCum = [0]
for i in map(int,input().split()):aCum+=[aCum[-1]+i]
aCum = aCum[1:]

#aX = [int(x) for x in input().split()]
#aCum = [0]*iN
#aCum[0] = aX[0]
#for i in range(1,iN):
#   aCum[i]=aCum[i-1]+aX[i]

def fCeil(iT,iR):
    return -1 * iT // iR * -1

def fCalcCost(iN,iX,aCum,iK):
    iCost = (iN + iK ) * iX + 5 * aCum[-1]
    for i in range(2,fCeil(iN,iK) ):
        iCost += 2 * aCum[-1 * i * iK -1]
    return iCost

iTotalCost = fCalcCost(iN,iX,aCum,1)
for iK in range(2,fCeil(iN,2) + 1):
    iTotalCost = min(iTotalCost,fCalcCost(iN,iX,aCum,iK))
print(iTotalCost)


# Optimized solution
iN ,iX  = [int(x) for x in input().split()]
aX = [int(x) for x in input().split()]

aCum = [0]*iN
aCum[0] = aX[0]
for i in range(1,iN):
    aCum[i]=aCum[i-1]+aX[i]

def fCeil(iT,iR):
    return -1 * iT // iR * -1

def fCalcCost(iN,iX,aCum,iK):
    iCost = (iN + iK ) * iX + 5 * aCum[-1]
    for i in range(2,fCeil(iN,iK) ):
        iCost += 2 * aCum[-1 * i * iK -1]
    return iCost

#枝刈りのテスト
#これ通用するのかな
iTotalCost = fCalcCost(iN,iX,aCum,1)
for iK in range(2,fCeil(iN,2) + 1):
    iThisCost = fCalcCost(iN,iX,aCum,iK)
    if iThisCost > iTotalCost:
        break
    else:
        iTotalCost = iThisCost
print(iTotalCost)
# Original solution

iN ,iX  = [int(x) for x in input().split()]
aX = [int(x) for x in input().split()]

aCum = [0]*iN
aCum[0] = aX[0]
for i in range(1,iN):
    aCum[i]=aCum[i-1]+aX[i]

def fCeil(iT,iR):
    return -1 * iT // iR * -1
#マネして記法を圧縮してみたがどうだろう
def fCalcCost(iN,iX,aCum,iK):
    return (iN + iK ) * iX + 5 * aCum[-1] +sum(2*aCum[-i*iK -1] for i in range(2,fCeil(iN,iK)))

iTotalCost = fCalcCost(iN,iX,aCum,1)
iULim = fCeil(iN,2) + 1
for iK in range(2,fCeil(iN,2)+1):
    iThisCost = fCalcCost(iN,iX,aCum,iK)
    if iThisCost > iTotalCost:
        break
    else:
        iTotalCost = iThisCost
print(iTotalCost)


# Optimized solution
iN ,iX  = [int(x) for x in input().split()]
#かえって遅い？
aCum = [0]
for x in input().split():
    aCum += [aCum[-1] + int(x)]

def fCeil(iT,iR):
    return -1 * iT // iR * -1

def fCalcCost(iN,iX,aCum,iK):
    iCost = (iN + iK ) * iX + 5 * aCum[-1]
    for i in range(2,fCeil(iN,iK) ):
        iCost += 2 * aCum[iN - i * iK ]
    return iCost

#枝刈り
iTotalCost = fCalcCost(iN,iX,aCum,1)
for iK in range(2,fCeil(iN,2) + 1):
    iThisCost = fCalcCost(iN,iX,aCum,iK)
    if iThisCost > iTotalCost:
        break
    else:
        iTotalCost = iThisCost
print(iTotalCost)
# Original solution
iN ,iX  = [int(x) for x in input().split()]
aCum = [0]
for x in input().split():
    aCum += [aCum[-1] + int(x)]

def fCeil(iT,iR):
    return -1 * iT // iR * -1

def fCalcCost(iN,iX,aCum,iK):
    iCost = (iN + iK ) * iX + 5 * aCum[iN]
    for i in range(2,fCeil(iN,iK) ):
        iCost += 2 * aCum[iN - i * iK ]
    return iCost


if 1 < iN :

    iULim = fCeil(iN,2)+1
    iLLim = 1
    def fSearchLowCost(iL,iLCost,iU,iUCost,iN,iX,aCum):
        if iU - iL < 2 * iX :
            iTotalCost = min(iLCost,iUCost)
            for iK in range(iL+1,iU) :
                iThisCost = fCalcCost(iN,iX,aCum,iK)
                iTotalCost = min(iThisCost,iTotalCost)
            return iTotalCost
        else:
            iM = (iU + iL) // 2
            iMCost = fCalcCost(iN,iX,aCum,iM)
            if iLCost < iUCost :
                return fSearchLowCost(iL,iLCost,iM,iMCost,iN,iX,aCum)
            else :
                return fSearchLowCost(iM,iMCost,iU,iUCost,iN,iX,aCum)

    print((fSearchLowCost(iLLim,fCalcCost(iN,iX,aCum,iLLim),iULim,fCalcCost(iN,iX,aCum,iULim),iN,iX,aCum)))
else:
    print((2*iX + 5*aX[0]))


# Optimized solution
iN ,iX  = [int(x) for x in input().split()]
aCum = [0]
for x in input().split():
    aCum += [aCum[-1] + int(x)]

def fCeil(iT,iR):
    return -1 * iT // iR * -1

def fCalcCost(iN,iX,aCum,iK):
    iCost = (iN + iK ) * iX + 5 * aCum[iN]
    for i in range(2,fCeil(iN,iK) ):
        iCost += 2 * aCum[iN - i * iK ]
    return iCost


if 1 < iN :

    iULim = fCeil(iN,2)+1
    iLLim = 1
    def fSearchLowCost(iL,iLCost,iU,iUCost,iN,iX,aCum):
        if iU - iL <= iX :
            iTotalCost = min(iLCost,iUCost)
            for iK in range(iL+1,iU) :
                iThisCost = fCalcCost(iN,iX,aCum,iK)
                iTotalCost = min(iThisCost,iTotalCost)
            return iTotalCost
        else:
            iM = (iU + iL) // 2
            iMCost = fCalcCost(iN,iX,aCum,iM)
            if iLCost < iUCost :
                return fSearchLowCost(iL,iLCost,iM,iMCost,iN,iX,aCum)
            else :
                return fSearchLowCost(iM,iMCost,iU,iUCost,iN,iX,aCum)

    print((fSearchLowCost(iLLim,fCalcCost(iN,iX,aCum,iLLim),iULim,fCalcCost(iN,iX,aCum,iULim),iN,iX,aCum)))
else:
    print((2*iX + 5*aX[0]))
# Original solution
iN ,iX  = [int(x) for x in input().split()]
aCum = [0]
for x in input().split():
    aCum += [aCum[-1] + int(x)]

def fCeil(iT,iR):
    return -1 * iT // iR * -1

def fCalcCost(iN,iX,aCum,iK):
    iCost = (iN + iK ) * iX + 5 * aCum[iN]
    for i in range(2,fCeil(iN,iK) ):
        iCost += 2 * aCum[iN - i * iK ]
    return iCost


if 1 < iN :

    iULim = fCeil(iN,2)+1
    iLLim = 1
    def fSearchLowCost(iL,iLCost,iU,iUCost,iN,iX,aCum):
        if iU - iL <= iX :
            iTotalCost = min(iLCost,iUCost)
            for iK in range(iL+1,iU) :
                iTotalCost = min(iTotalCost,fCalcCost(iN,iX,aCum,iK))
            return iTotalCost
        else:
            iM = (iU + iL) // 2
            iMCost = fCalcCost(iN,iX,aCum,iM)
            if iLCost < iUCost :
                return fSearchLowCost(iL,iLCost,iM,iMCost,iN,iX,aCum)
            else :
                return fSearchLowCost(iM,iMCost,iU,iUCost,iN,iX,aCum)

    print((fSearchLowCost(iLLim,fCalcCost(iN,iX,aCum,iLLim),iULim,fCalcCost(iN,iX,aCum,iULim),iN,iX,aCum)))
else:
    print((2*iX + 5*aX[0]))


# Optimized solution
iN ,iX  = [int(x) for x in input().split()]
aCum = [0]
for x in input().split():
    aCum += [aCum[-1] + int(x)]

def fCeil(iT,iR):
    return -1 * iT // iR * -1

def fCalcCost(iN,iX,aCum,iK):
    iCost = (iN + iK ) * iX + 5 * aCum[iN]
    for i in range(2,fCeil(iN,iK) ):
        iCost += 2 * aCum[iN - i * iK ]
    return iCost

def fSearchLowCost(iL,iLCost,iU,iUCost,iN,iX,aCum):
    if iU - iL <= iX :
        iTotalCost = min(iLCost,iUCost)
        for iK in range(iL+1,iU) :
            iTotalCost = min(iTotalCost,fCalcCost(iN,iX,aCum,iK))
        return iTotalCost
    else:
        iM = (iU + iL) // 2
        iMCost = fCalcCost(iN,iX,aCum,iM)
        if iLCost < iUCost :
            return fSearchLowCost(iL,iLCost,iM,iMCost,iN,iX,aCum)
        else :
            return fSearchLowCost(iM,iMCost,iU,iUCost,iN,iX,aCum)

if 1 < iN :

    iULim = fCeil(iN,2)+1
    iLLim = 1
    print((fSearchLowCost(iLLim,fCalcCost(iN,iX,aCum,iLLim),iULim,fCalcCost(iN,iX,aCum,iULim),iN,iX,aCum)))
else:
    print((2*iX + 5*aX[0]))
# Original solution
import math
import sys
n,x= list(map(int,input().split()))
a = list(map(int, sys.stdin.readline().split()))
ru = [0]*(n+1)
for i in range(1,n+1):
  ru[i] = ru[i-1]+a[i-1]
ans = float("inf")
for i in range(1,n+1):
  tmp = x*i
  l = math.ceil(n/i)
  for j in range(1,l+1):
    if ans <= tmp:
      break
    if j == 1:
        m = -i*(j+1)-1
        if m < -n:
          m = -n-1
        tmp += (ru[n]-ru[m])*5
    else:
        m = -i*(j+1)-1
        if m < -n:
          m = -n-1
        if -i*j-1 < -n:
          break
        tmp += (ru[-i*j-1]-ru[m])*(2*j+3)
  ans = min(ans,tmp)
print((ans+n*x))

# Optimized solution
import sys
n,x= list(map(int,input().split()))
a = list(map(int, sys.stdin.readline().split()))
ru = [0]*(n+1)
for i in range(1,n+1):
  ru[i] = ru[i-1]+a[i-1]
ans = float("inf")
for i in range(1,(n+1)//2+1):
  tmp = x*i+ru[n]*5
  j = n-i*2
  while j > 0:
    tmp += ru[j]*2
    j -= i
  ans = min(ans,tmp)
print((ans+n*x))
# Original solution


def main():
    string = input().strip()
    k = int(eval(input()))
    s = set()
    length = len(string)
    for i in range(length):
        for j in range(i, length):
            s.add(string[i:j+1])
    print((sorted(s)[k - 1]))


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    string = input().strip()
    k = int(eval(input()))
    s = set()
    for char in sorted(set(string)):
        for i in range(len(string)):
            if string[i] == char:
                s.add(string[i])
                s.add(string[i:i+1])
                s.add(string[i:i+2])
                s.add(string[i:i+3])
                s.add(string[i:i+4])
                s.add(string[i:i+5])
        if len(s) >= k:
            print((sorted(s)[k - 1]))
            return


if __name__ == '__main__':
    main()