Cutting Bamboos

Limits 2s, 512 MB

There are $n$ bamboos in a row. Khan the bamboo cutter is going to cut them all one by one. He can do one of the following operations at a time.

Each bamboo $i$ has a strength of $s_i$. But each time Khan cuts a bamboo, his axe becomes more dull. So at the $x$th time if he wants to cut the $i$th bamboo, he will need to use $x \times s_i$ calories. Khan doesn't want to use too many calories. So he asks your help to find out the lowest calorie he can use to cut all the bamboos.


First line of input contains $n$ $(1\le n\le 2000)$ the number of bamboos. The next line contains $n$ integers $s_i$ $(1\le s_i\le 10^{5})$ the strength of each bamboo.


You have to print the minimum number of calories to cut all the bamboos.


2 1 3 5 4