ATMCMXNG - Richie Rich and Keen Bean

no tags 

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:
1
3
40 60 20

Output:
2400

hide comments
smso: 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

Simes: 2018-11-01 06:42:08

@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
supernanren: 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.

Simes: 2018-10-26 17:11:58

I agree the test data is suspicious, but none of my asserts fail.

[Rampage] Blue.Mary: 2018-10-06 11:01:12

Test cases can not be right, my assertion failed on 0 <= x <= 99.

Simes: 2018-09-22 12:31:28

Same problem as MIXTURES

Last edit: 2019-09-20 08:29:40
milw0rm_007: 2018-09-22 05:35:15

Can someone please explain the test case?

shashankpathak: 2018-09-11 18:31:55

test cases are right

[Rampage] Blue.Mary: 2018-09-11 05:24:03

At least one input file contains some a[i], which is not in range [0, 99]. Please check the test data.

trijeet: 2018-07-06 02:57:48

Kindly enable submissions.


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