#L15399. [NOISG 2026 Prelim] Area 2

[NOISG 2026 Prelim] Area 2

Problem Description

Ziv has nn pairs of sticks, numbered from 1 to nn. The ii-th pair consists of two sticks, each of length a[i]a[i].

Ziv intends to construct a rectangular frame by selecting two distinct indices xx and yy (x≠yx \ne y). The resulting rectangle will have side lengths a[x]a[x] by a[y]a[y], and an area equal to a[x]×a[y]a[x] \times a[y].

Help Ziv find the maximum possible area of a rectangular frame he can construct.

Your program must read from standard input.

The first line of input contains one integer nn.

The next nn lines of input each contain one integer. The ii-th of these lines contains a[i]a[i].

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.

Only one frame is possible: 8×98 \times 9 with an area of 7272.

There are only 3 frames possible:

  • 16×44=70416 \times 44 = 704
  • 16×18=28816 \times 18 = 288
  • 44×18=79244 \times 18 = 792

The largest area is 792792.

For all test cases, the input will satisfy the following bounds:

  • 2≤n≤102 \le n \le 10
  • 1≤a[i]≤10001 \le a[i] \le 1000 for all 1≤i≤n1 \le i \le n

Your program will be tested on input instances that satisfy the following restrictions:

Subtask Score Additional Constraints
0 Sample test cases
1 20 n=2n = 2
2 n=3n = 3
3 60 No additional constraints
2
8
9
72
3
16
44
18
792
8
6
7
6
7
99
99
69
1
9801