#C11767. Maximum Product of Array Elements

    ID: 41119 Type: Default 1000ms 256MiB

Maximum Product of Array Elements

Maximum Product of Array Elements

You are given several test cases. In each test case, you are provided with an array of integers. Your task is to determine the maximum product of two elements from the array. Note that the two elements can be the same element (i.e. pairing an element with itself is allowed).

Formally, given an array \(a_1, a_2, \dots, a_n\), you need to compute the value:

[ \max_{1 \le i, j \le n} {a_i \times a_j} ]

Note: If the array contains only one element, then the answer is the element multiplied by itself.

It is guaranteed that each test case contains at least one element.

inputFormat

The input is given via standard input and is structured as follows:

  1. An integer \(T\) representing the number of test cases.
  2. For each test case:
    1. An integer \(n\) representing the number of elements in the array.
    2. A line containing \(n\) space-separated integers.

Consider that the input is read from stdin.

outputFormat

For each test case, output the maximum product on a separate line to stdout.

## sample
3
5
1 3 5 2 4
3
10 20 30
4
7 2 3 9
25

900 81

</p>