A hardware company is building a machine with exactly hardware components. There are many components available, and the profit factor of each component is known. The profit obtained by the machine is the product of the profit factors of the hardware components used to build that machine.
However, there is a catch. Three different components with numbers can be used to build the machine if and only if their profit factors are .
Calculate the maximum possible profit that a valid machine consisting of three components can have, or decide that it's impossible to build any machine. Complete the function maximumProfit which takes in the integer array denoting the profit factors of all components and returns a single integer denoting the answer.
The first line contains a single integer , denoting the number of available components. Components are numbered to .
The second line contains space-separated integers , i.e the integer array denoting the profit factors of the components.
Print if it's impossible to build any machine. Otherwise, print a single integer denoting the maximum possible profit that a valid machine consisting of components can have.
Sample Input 0
710 2 -10 6 1 0 8
Sample Output 0
We use 1-based indexing for this explanation.There are hardware components available.
2nd, 4th and 7th component can be used to build the machine since (because , and ). The profit obtained by using the machine is , which is maximum possible.