P15399 [NOISG 2026 Prelim] Area 2

Description

Ziv has $n$ pairs of sticks, numbered from 1 to $n$. The $i$-th pair consists of two sticks, each of length $a[i]$. Ziv intends to construct a rectangular frame by selecting two **distinct** indices $x$ and $y$ ($x \ne y$). The resulting rectangle will have side lengths $a[x]$ by $a[y]$, and an area equal to $a[x] \times a[y]$. Help Ziv find the maximum possible area of a rectangular frame he can construct.

Input Format

Your program must read from standard input. The first line of input contains one integer $n$. The next $n$ lines of input each contain one integer. The $i$-th of these lines contains $a[i]$.

Output Format

Your program must print to standard output. Output one integer, the maximum possible area of a rectangular frame Ziv can form. The output should contain only a single integer. Do not print any additional text such as `Enter a number` or `The answer is`.

Explanation/Hint

### Sample Test Case 1 Explanation Only one frame is possible: $8 \times 9$ with an area of $72$. ### Sample Test Case 2 Explanation There are only 3 frames possible: - $16 \times 44 = 704$ - $16 \times 18 = 288$ - $44 \times 18 = 792$ The largest area is $792$. ### Subtasks For all test cases, the input will satisfy the following bounds: - $2 \le n \le 10$ - $1 \le a[i] \le 1000$ for all $1 \le i \le n$ Your program will be tested on input instances that satisfy the following restrictions: | Subtask | Score | Additional Constraints | |:-------:|:-----:|:-------------------------------:| | 0 | 0 | Sample test cases | | 1 | 20 | $n = 2$ | | 2 | 20 | $n = 3$ | | 3 | 60 | No additional constraints |