cswork / OA打开练习工作台

AmazonOA #211

Maximize Total Area of Rectangles (SDE 2)

估计中等可在线判题

考点(AI 标注)贪心调度原地数组

Each stick may go unused or be used in at most one rectangle, and each stick's length can be reduced by at most 1 but never increased. Each rectangle must use four sticks forming two pairs of equal sides; a square is also valid. First maximize the total area of all rectangles, then take it modulo 1000000007.

输入格式

The first line contains n; the second line contains the stick lengths. 1≤n≤100000, 2≤length≤10000.

输出格式

Output a single integer, the answer.

样例 1

输入:

6
2 6 2 6 3 5

输出:

12

样例 2

输入:

8
2 3 3 4 6 8 8 6

输出:

54

样例 3

输入:

5
3 4 5 5 6

输出:

20

样例说明

The answers are 12, 54 and 20. In the third example 6 and 5 pair up as 5, and the other 5 and 4 pair up as 4, for area 20.