C - Make a Rectangle Editorial /

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 300300

問題文

太さが無視できる棒が NN 本あります. ii 番目の棒の長さは AiA_i です.

すぬけ君は,これらの棒から 44 本の異なる棒を選び,それらの棒を辺として長方形(正方形を含む)を作りたいです. 作ることができる最大の長方形の面積を求めてください.

制約

  • 4N1054 \leq N \leq 10^5
  • 1Ai1091 \leq A_i \leq 10^9
  • AiA_i は整数

入力

入力は以下の形式で標準入力から与えられる。

NN
A1A_1 A2A_2 ... ANA_N

出力

すぬけ君が作ることのできる最大の長方形の面積を出力せよ. ただし,長方形を作れない場合は,00 を出力せよ.


入力例 1Copy

Copy
6
3 1 2 4 2 1

出力例 1Copy

Copy
2

1×21 \times 2 の長方形を作ることができます.


入力例 2Copy

Copy
4
1 2 3 4

出力例 2Copy

Copy
0

長方形を作ることはできません.


入力例 3Copy

Copy
10
3 3 3 3 4 4 4 5 5 5

出力例 3Copy

Copy
20

Score : 300300 points

Problem Statement

We have NN sticks with negligible thickness. The length of the ii-th stick is AiA_i.

Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Constraints

  • 4N1054 \leq N \leq 10^5
  • 1Ai1091 \leq A_i \leq 10^9
  • AiA_i is an integer.

Input

Input is given from Standard Input in the following format:

NN
A1A_1 A2A_2 ... ANA_N

Output

Print the maximum possible area of the rectangle. If no rectangle can be formed, print 00.


Sample Input 1Copy

Copy
6
3 1 2 4 2 1

Sample Output 1Copy

Copy
2

1×21 \times 2 rectangle can be formed.


Sample Input 2Copy

Copy
4
1 2 3 4

Sample Output 2Copy

Copy
0

No rectangle can be formed.


Sample Input 3Copy

Copy
10
3 3 3 3 4 4 4 5 5 5

Sample Output 3Copy

Copy
20


2025-04-07 (Mon)
21:48:51 +00:00