PivotOJ

Sequence

시간 제한: 1000ms메모리 제한: 1024MB출처: BOI 2023BOJ 31979

문제

A sequence of positive integers (x1,…,xm)(x_1,\ldots,x_m) is good if x1=1x_1 = 1 and for each 1<j≤m1 < j \leq m we have either xj=xj−1+1x_j=x_{j-1}+1 or xj=xk⋅xlx_j=x_k\cdot x_l for some kk and ll with 0<k≤l<j0< k\leq l< j. For instance, the sequences (1,1)(1,1) and (1,2)(1,2) are both good, but the sequence (1,3)(1,3) is not good. For nn given integers w1,…,wnw_1,\ldots,w_n define the weight of an integer sequence (x1,…,xm)(x_1,\ldots,x_m) satisfying 1≤xj≤n1\leq x_j \leq n for each 1≤j≤m1\leq j\leq m as \[ w_{x_1} +\cdots +w_{x_m}\,.\] For instance, given the weights w1=10,w2=42,w3=1w_1=10, w_2=42,w_3= 1, the weight of the sequence (1,1)(1,1) is 2020 and the weight of the sequence (1,3)(1,3) is 1111. For 1≤v≤n1\leq v\leq n, define svs_v as the smallest possible weight of a good sequence containing the value vv.

Your task is to determine the values s1,…,sns_1,\ldots ,s_n.

입력

The first line of input consists of the integer nn, the number of weights. The next nn lines contain the integer weights w1,…,wnw_1, \ldots, w_n.

출력

Print nn lines containing s1s_1, …\ldots, sns_n in order.

예제

예제 1

입력
3
10
42
1
출력
10
52
53
코드를 제출하려면 로그인하세요.