525C.md (2085B)
1 Source: https://codeforces.com/problemset/problem/525/C 2 3 C. Ilya and Sticks 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 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*. 22 23 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. 24 25 Sticks with lengths *a*1, *a*2, *a*3 and *a*4 can make a rectangle if the following properties are observed: 26 27 * *a*1 ≤ *a*2 ≤ *a*3 ≤ *a*4 28 * *a*1 = *a*2 29 * *a*3 = *a*4 30 31 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. 32 33 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. 34 35 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? 36 37 Input 38 39 The first line of the input contains a positive integer *n* (1 ≤ *n* ≤ 105) — the number of the available sticks. 40 41 The second line of the input contains *n* positive integers *l**i* (2 ≤ *l**i* ≤ 106) — the lengths of the sticks. 42 43 Output 44 45 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. 46 47 Examples 48 49 Input 50 51 ``` 52 4 53 2 4 4 2 54 ``` 55 56 Output 57 58 ``` 59 8 60 ``` 61 62 Input 63 64 ``` 65 4 66 2 2 3 5 67 ``` 68 69 Output 70 71 ``` 72 0 73 ``` 74 75 Input 76 77 ``` 78 4 79 100003 100004 100005 100006 80 ``` 81 82 Output 83 84 ``` 85 10000800015 86 ```