Kstar is hosting a party and knows that exactly people will come, and the order in which they will enter the house. Each person has an integer energy level, which is also known to Kstar.
The synergy level between a pair of people is the product of the two people’s energy levels. The combined synergy in the house is equal to the sum of the synergy levels of all distinct pairs of people in the house. Note that Kstar can choose to lock everyone out before anyone comes in.
Kstar wants to start the party after some people have arrived and the energy level is maximized. After which person should Kstar lock the door and stop people from getting in? If there are multiple times where locking the door would yield the maximum synergy, output the first such possible time.
The first line of input will contain , the number of people invited to Kstar’s party. The next lines will contain an integer , the energy level of the person.
Output the least number of people Kstar should let in before closing the door and locking everyone out, in order to maximize total synergy.
4 1 2 8 -5
Explanation for Sample Input
After the first person comes in, the combined synergy is .
After the second person comes in, the combines synergy is .
After the third person comes in, the combines synergy is .
After the fourth person comes in, the combines synergy is .
Since the combined synergy was the maximum when the third person comes in, Kstar should lock the door after the third person comes in.