Brewing potion 8 - MarisaOJ: Marisa Online Judge

Brewing potion 8

Time limit: 1000 ms
Memory limit: 256 MB
Marisa has $n$ colorful potion bottles arranged in a row. Each bottle, labeled $i$, has a color $A_i$ ranging from $0$ to $99$. Marisa aims to combine all the bottles into a single bottle. She can select two adjacent bottles with colors $a$ and $b$, and mix them to create a new bottle with a color of $(a+b) \mod 100$. The amount of fumes released during this mixing process is given by $a \times b$. To minimize the amount of fumes released, Marisa needs to determine the minimum amount of fumes when she mixes all $n$ bottles together. ### Input - A single line contains an integer $n$. - The second line contains $n$ integers $A_i$. ### Output - Print the minimum amount of fumes. ### Constraints - $1 \le n \le 500$. ### Example Input: ``` 3 40 60 20 ``` Output: ``` 2400 ```