OpenKattis
ICPC Asia Jakarta 2020 Official Team Training 2 (16 Dec)

Start

2020-12-15 18:00 AKST

ICPC Asia Jakarta 2020 Official Team Training 2 (16 Dec)

End

2020-12-15 23:00 AKST
The end is near!
Contest is over.
Not yet started.
Contest is starting in -401 days 6:15:11

Time elapsed

5:00:00

Time remaining

0:00:00

Problem A
Inquiry I

The Bureau for Artificial Problems in Competitions wants you to solve the following problem: Given $n$ positive integers $a_1, \dots , a_ n$, what is the maximal value of

\[ \left(a_1^2 + \dots + a_ k^2\right) \cdot \left(a_{k+1} + \dots + a_ n\right)? \]

Input

  • A single line containing an integer $2\leq n\leq 10^6$.

  • Then follow $n$ lines, the $i$th of which contains the integer $1 \leq a_ i \leq 100$.

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