Under construction

Still being built. Things may change

Boards

Interview

Time limit5sMemory limit1024 MB

Summary
Given N board lengths, find the largest square area whose four equal sides can be cut from the boards by shortening them.
Level

Easy3 of 10

Topics
Sorting, Greedy
Solved
No attempts yet

Problem

Bajtek wants to build a large square sandbox. The sandbox needs only four boards of equal length. Unfortunately, when Bajtek bought boards at the sawmill, he forgot this and bought NN boards whose lengths are not necessarily equal. Bajtek may (but does not have to) shorten his boards first, and then choose four pieces of equal length to build the sandbox. A board can only be shortened, not split. For example, you cannot get two boards of length 2 from one board of length 4. Bajtek does not like fractions, so all board lengths are integers, and all shortened lengths must also be integers.

Write a program that reads the lengths of the boards Bajtek has, finds the area of the largest sandbox he can build, and prints the result to standard output.

Input

The first line contains one natural number NN (1≤N≤1 000 0001 \le N \le 1\,000\,000), the number of boards Bajtek has. The second and last line contains NN natural numbers L1,L2,…,LNL_1, L_2, \ldots, L_N (1≤Li≤1091 \le L_i \le 10^9), separated by single spaces. These are the lengths of the boards.

Output

The first and only line of output contains one integer, the area of the largest square sandbox that can be built under the conditions above. If no sandbox can be built, print 00.

Examples2

  1. Example 1

    Input
    7
    6 3 7 6 5 8 10
    
    Expected output
    36
    
  2. Example 2

    Input
    2
    2 6
    
    Expected output
    0