Harry Potter has n mixtures in front of him, arranged in a row.Each mixture has one of 100 different colors (colors have numbers from 0 to 99).

He wants to mix all these mixtures together. At each step, he is going to take two mixtures that stand next to each other and mix them together, and put the resulting mixture in their place.


When mixing two mixtures of colors a and b, the resulting mixture will have the color (a+b) mod 100.


Also, there will be some smoke in the process. The amount of smoke generated when mixing two mixtures of colors a and b is a*b.

Find out what is the minimum amount of smoke that Harry can get when mixing all the ixtures together.



Input

There will be a number of test cases in the input.

The first line of each test case will contain n, the number of mixtures, 1 ≤ n ≤ 100.

The second line will contain n integers between 0 and 99 - the  initial colors of the mixtures.


Output

For each test case, output the minimum amount of smoke.



Example

Input:
2
18 19
3
40 60 20

Output:
342
2400


In the second test case, there are two possibilities:

 first mix 40 and 60 (smoke: 2400), getting 0, then mix 0 and 20 (smoke: 0); total amount of smoke is 2400
 first mix 60 and 20 (smoke: 1200), getting 80, then mix 40 and 80 (smoke: 3200); total amount of smoke is 4400


The first scenario is the correct approach since it minimizes the amount of smoke produced.
def create_mod_matrix(colors):
	if (colors):
		mod_mat = [[0] * len(colors) for i in range(len(colors))]
		for i in range(len(colors)):
			for j in range(i, len(colors)):
				if (i == j):
					mod_mat[i][i] = colors[i]
				else:
					mod_mat[i][j] = (mod_mat[i][j-1] + colors[j] ) % 100
		return mod_mat

def create_smoke_mat(no_of_colors):

	smoke_mat = [[0] * no_of_colors for _ in range(no_of_colors)]
	return smoke_mat

def compute_min_smoke(colors= [40, 60, 20]):
	mod_mat = create_mod_matrix(colors)

	no_of_colors = len(colors)
	smoke_mat = create_smoke_mat(no_of_colors)

	for size in range(1,no_of_colors+1):
		for i in range (no_of_colors - size):
			values = []
			for k in range(i, i+size):
				x = smoke_mat[k-i][i] + smoke_mat[i+size-k-1][k+1] + mod_mat[i][k] * mod_mat[k+1][i+size]
				values.append(x)
			smoke_mat[size][i] = min(values)

	return smoke_mat[no_of_colors-1][0]

def launch():
    try:
        while(True):

            no_of_colors = int(raw_input())
            colors = [int(x) for x in  raw_input().split()]
            assert (no_of_colors == len(colors))
            answer = compute_min_smoke(colors)
            print answer
    except:
        pass

launch()