Codeforces Round 297 (Div. 2)
C
Ilya and Sticks
Codeforces
1600
原题
← BD →
翻译中…

In the evening, after the contest Ilya was bored, and he really felt like maximizing. He remembered that he had a set of $*n*$ sticks and an instrument. Each stick is characterized by its length $*l*_{*i*}$.

翻译中…

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.

翻译中…

Sticks with lengths $*a*_{1}$, $*a*_{2}$, $*a*_{3}$ and $*a*_{4}$ can make a rectangle if the following properties are observed:

翻译中…
  • $*a*_{1} ≤ *a*_{2} ≤ *a*_{3} ≤ *a*_{4}$
  • $*a*_{1} = *a*_{2}$
  • $*a*_{3} = *a*_{4}$
翻译中…

A rectangle can be made of sticks with lengths of, for example, $3 3 3 3$ or $2 2 4 4$. A rectangle cannot be made of, for example, sticks $5 5 5 7$.

翻译中…

Ilya also has an instrument which can reduce the length of the sticks. The sticks are made of a special material, so the length of each stick can be reduced by at most one. For example, a stick with length $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

翻译中…

The first line of the input contains a positive integer $*n*$ ($1 ≤ *n* ≤ 10^{5}$) — the number of the available sticks.

翻译中…

The second line of the input contains $*n*$ positive integers $*l*_{*i*}$ ($2 ≤ *l*_{*i*} ≤ 10^{6}$) — 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.

翻译中…

样例

Input #1
4
2 4 4 2
Output #1
8
InputCopy OutputCopy
Input #2
4
2 2 3 5
Output #2
0
InputCopy OutputCopy
Input #3
4
100003 100004 100005 100006
Output #3
10000800015
InputCopy OutputCopy
题目信息
题号
525C
时间限制
2 s
内存限制
256 MB
标签
贪心
数学
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。