YJQQQAQ and the function

Time Limit: 2000ms
Memory Limit: 65536KB
This problem will be judged on HDU. Original ID: 5662
64-bit integer IO format: %I64d      Java class name: Main

Description

YJQQQAQ has an array $A$ of length $n$. He defines a function $f_{l,r,k}$ where $l,r,k$ are positive integers that satisfies $l\leq r$ and $r\times k\leq n$, and the value of the function equals to $p\times q\times\lfloor\sqrt{k}\rfloor$ where $p$ equals to the sum value of $A_{l\times k},A_{\left(l+1\right)\times k},...,A_{r\times k}$ and $q$ equals to the minimal value of them. YJQQQAQ wants to choose the positive integers $l,r,k$ carefully to maximize the value of the function.

Input

The first line contains an integer $T\left(1\leq T\leq 3\right)$——The number of the test cases. For each test case:
The first line contains an integers $n\left(1\leq n\leq300,000\right)$.
The second line contains $n$ integers describing the given array $A$, the $i$th integer is $A_i\left(1\leq A_i\leq1,000,000\right)$. Between each two adjacent integers there is a white space separated.

Output

For each test case, the only line contains the only integer that is the maximum value of the function.

Sample Input

1
3
2 3 1

Sample Output

10

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .