Boards
InterviewTime limit5sMemory limit1024 MB
Given N board lengths, find the largest square area whose four equal sides can be cut from the boards by shortening them.
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 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 (), the number of boards Bajtek has. The second and last line contains natural numbers (), 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 .