C. Ilya and Sticks
time limit per test
memory limit per test
input
output
n sticks and an instrument. Each stick is characterized by its length li.
Ilya decided to make a rectangle from the sticks. And due to his whim, he decided to make rectangles in such a way that maximizes their total area. Each stick is used in making at most one rectangle, it is possible that some of sticks remain unused. Bending sticks is not allowed.
a1, a2, a3 and a4
- a1 ≤a2 ≤a3 ≤a4
- a1 =a2
- a3 =a4
3 3 3 3 or 2 2 4 4. A rectangle cannot be made of, for example, sticks5 5 5 7.
5 can either stay at this length or be transformed into a stick of length 4.
You have to answer the question — what maximum total area of the rectangles can Ilya get with a file if makes rectangles from the available sticks?
Input
n (1 ≤ n ≤ 105) — the number of the available sticks.
n positive integers li (2 ≤ li ≤ 106) — the lengths of the sticks.
Output
The first line of the output must contain a single non-negative integer — the maximum total area of the rectangles that Ilya can make from the available sticks.
Sample test(s)
input
4 2 4 4 2
output
8
input
4 2 2 3 5
output
0
input
4 100003 100004 100005 100006
output
10000800015
贪心,凑当前尽量长的对子