ATMCMXNG - Richie Rich and Keen Bean

Dr. Keen Bean has great love for chemistry. He has 100 elements with atomic number from 0-99. Dr. Kean Bean wants to react(mix) all elements together. At each turn he mix two elements together placed next to each other and replace the resulting element in their place. When mixing two elements with atomic number a and b, the resulting element atomic number will get modified and will be (a + b) % 100. The dangerous point is while mixing two elements there is production of toxic gas, whose toxicity level is a * b.

Dr. Keen Bean would like to produce very less amount of toxic gas. So he wants you to help him find minimum amount of toxic gas he can produce when mixing all elements together.

Input

The first line of input contains integerĀ  N (1 <= N <= 100), the number of elements. The second line will contain atomic numbers between 0-99. The initial atomic numbers of elements.

Output

Output the minimum amount of toxic gas Dr. Keen bean can produce.

Example

Input:
3
40 60 20

Output:
2400

Added by:dynamicgreedy
Date:2018-07-04
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All

hide comments
2024-08-13 05:18:15
STRANGE

Read first number T - as count testcase give me 3 WA =(
2019-09-20 04:02:37
Problem copied from:
https://www.spoj.com/problems/MIXTURES/

Input should be:
2
18 19
3
40 60 20
2018-11-01 06:42:08 Simes
@supernanren - many thanks - that was exactly the problem. But why did nobody else mention it? It gets a thumbs down for that.

Last edit: 2018-11-01 06:44:29
2018-10-31 18:50:48
My AC suggest there's only one case each, and there is no number of test cases in the input. Should delete the "1" in the Example, it's misleading.
2018-10-26 17:11:58 Simes
I agree the test data is suspicious, but none of my asserts fail.
2018-10-06 11:01:12 [Rampage] Blue.Mary
Test cases can not be right, my assertion failed on 0 <= x <= 99.
2018-09-22 12:31:28 Simes
Same problem as MIXTURES

Last edit: 2019-09-20 08:29:40
2018-09-22 05:35:15
Can someone please explain the test case?
2018-09-11 18:31:55
test cases are right
2018-09-11 05:24:03 [Rampage] Blue.Mary
At least one input file contains some a[i], which is not in range [0, 99]. Please check the test data.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.