Can someone tell me how to solve this question that was asked in TCS CODEVITA ?

Pascal’s triangle giving binomial coefficients is well known. In this triangle, elements in each row can be obtained by adding two adjacent elements in the previous row. The pyramid of numbers we construct in this problem is similar to the Pascal triangle. We start with six numbers at the base of the pyramid, and construct the pyramid one layer at a time by adding the two adjacent numbers in the previous layer. For Example, starting with the numbers 1 2 3 4 5 6 in the base, we get the following pyramid.

The apex of the pyramid is filled with the product of the numbers in the row below instead of the sum.

![alt text][1]

In the above pyramid, the apex is filled with the number 48 x 64 =3072. The aim is to get the largest number possible at the apex of the pyramid.

The input will be a set of N positive integers. Six need to be chosen from these and arranged at the base to get the largest possible number at the top.

Input Format:

The first line of the input is N, the total number of integers that will be given.

The second line is a set of N (not necessarily distinct) comma separated positive integers from which the six numbers at the base need to be selected.

Output Format:

The output is one line with an integer representing the maximum value of the apex of the pyramid when six integers are selected and arranged suitably at the base.

**Constraints:**

N < 13

Integers provided for selection ≤ 100

**Example 1**

**Input**

8

10,4,74,61,8,37,2,35

**Output**

746415

**Explanation**

There are 8 numbers given, from which the 6 numbers in the base are to be selected and arranged so as to maximize the apex number. One way of doing this is in the figure below.

The product of the two numbers below the apex is 746415, which is the output.

![alt text][2]

**Example 2**

**Input**

10

37,93,56,10,77,82,72,82,39,7

**Output**

1786212

[1]: https://discuss.codechef.com/upfiles/PascalPyramid1.png

[2]: https://discuss.codechef.com/upfiles/PascalPyramid2.png