Haidora and suspicious formula#12281

Haidora and suspicious formula

2 seconds
256 megabytes
Medium

As a problemsetter, Haidora enjoys mixing operations in random forms. While he was playing with multiplication and addition, he came up with the following problem:

You are given an array of length (the array may contain both positive and negative integers). You are asked to find the maximum value of a_i \cdot a_j+a_k^2 for three distinct indices ,,and i.e i \neq j \neq k.

Haidora is tired from his exam so he asked you to solve this problem for him. Can you help Haidora?

Input

The first line contains single integer (1 \le t \le 1000) — the number of test cases.

The first line of test case contains single integer (3 \le n \le 2\cdot 10^5) — the length of the array .

The second line of each test case contains integers separated by spaces such that (-10^6 \leq a_i \leq 10^6).

It's guaranteed that \sum n \le 2 \cdot 10^5.

Output

Output a single integer: the answer to the problem.

Please note! that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).

It can be shown that the for each test case doesn't exceed 10^{18}

Examples

Example 1

Loading
Loading

Scoring

  1. Subtask ( points): (1 \leq \sum n \leq 500).

  2. Subtask ( points): (1 \leq \sum n \leq 5000).

  3. Subtask ( points): (0 \leq a_i \leq 10^6).

  4. Subtask ( points): No additional constraints.