시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB164430.769%

문제

A sequence of positive integers $(x_1,\ldots,x_m)$ is good if $x_1 = 1$ and for each $1 < j \leq m$ we have either $x_j=x_{j-1}+1$ or $x_j=x_k\cdot x_l$ for some $k$ and $l$ with $0< k\leq l< j$. For instance, the sequences $(1,1)$ and $(1,2)$ are both good, but the sequence $(1,3)$ is not good. For $n$ given integers $w_1,\ldots,w_n$ define the weight of an integer sequence $(x_1,\ldots,x_m)$ satisfying $1\leq x_j \leq n$ for each $1\leq j\leq m$ as \[ w_{x_1} +\cdots +w_{x_m}\,.\] For instance, given the weights $w_1=10, w_2=42,w_3= 1$, the weight of the sequence $(1,1)$ is $20$ and the weight of the sequence $(1,3)$ is $11$. For $1\leq v\leq n$, define $s_v$ as the smallest possible weight of a good sequence containing the value $v$.

Your task is to determine the values $s_1,\ldots ,s_n$.

입력

The first line of input consists of the integer $n$, the number of weights. The next $n$ lines contain the integer weights $w_1, \ldots, w_n$.

출력

Print $n$ lines containing $s_1$, $\ldots$, $s_n$ in order.

제한

We always have $1\leq n \leq 30\,000$ and $1\leq w_i \leq 10^6$ for each $1\leq i \leq n$.

서브태스크

번호배점제한
111

$n\leq 10$

210

$n\leq 300$, $w_1=\cdots=w_n = 1$

310

$n\leq 300$, $w_1=\cdots=w_n$

49

$n\leq 1400$, $w_1=\cdots=w_n = 1$

545

$n\leq 5000$

615

No additional constraints

예제 입력 1

3
10
42
1

예제 출력 1

10
52
53

채점 및 기타 정보

  • 예제는 채점하지 않는다.
  • 이 문제의 채점 우선 순위는 2이다.