Hide

Problem F
Inquiry I

The Bureau for Artificial Problems in Competitions wants you to solve the following problem: Given n positive integers a1,,an, what is the maximal value of

(a12++ak2)(ak+1++an)?

Input

  • A single line containing an integer 2n106.

  • Then follow n lines, the ith of which contains the integer 1ai100.

Output

Output the maximal value of the given expression.

Sample Input 1 Sample Output 1
5
2
1
4
3
5
168
Sample Input 2 Sample Output 2
2
1
1
1
Sample Input 3 Sample Output 3
10
8
5
10
9
1
4
12
6
3
13
10530
Hide

Please log in to submit a solution to this problem

Log in