Hide

Problem C
Sequence

Languages da de en et fi lt lv pl uk

A sequence of positive integers (x1,,xm) is good if x1=1 and for each 1<jm we have either xj=xj1+1 or xj=xkxl for some k and l with 0<kl<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 w1,,wn define the weight of an integer sequence (x1,,xm) satisfying 1xjn for each 1jm as

wx1++wxm.

For instance, given the weights w1=10,w2=42,w3=1, the weight of the sequence (1,1) is 20 and the weight of the sequence (1,3) is 11. For 1vn, define sv as the smallest possible weight of a good sequence containing the value v.

Your task is to determine the values s1,,sn.

Input

The first line of input consists of the integer n, the number of weights. The next n lines contain the integer weights w1,,wn.

Output

Print n lines containing s1, , sn in order.

Constraints and Scoring

We always have 1n30000 and 1wi106 for each 1in.

Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group you need to solve all test cases in the test group. Your final score will be the maximum score of a single submission.

Group

Points

Constraints

1

11

n10

2

10

n300, w1==wn=1

3

10

n300, w1==wn

4

9

n1400, w1==wn=1

5

45

n5000

6

15

No additional constraints

Sample Input 1 Sample Output 1
3
10
42
1
10
52
53
Hide

Please log in to submit a solution to this problem

Log in