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 Ai 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)mod100. The amount of fumes released during this mixing process is given by a×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 Ai. ### Output - Print the minimum amount of fumes. ### Constraints - 1≤n≤500. ### Example Input: 3406020 Output: 2400