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




#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

using namespace std;

int n;
int a[110005];

int cmp(const void *a,const void *b)
{
    return *(int*)b - *(int*)a;
}

int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        qsort(a,n,sizeof(a[0]),cmp);
        __int64 ans = 0;
        int flag = 0;
        __int64 x,y;
        int pf = 0;
        for(int i=0;i<n-1;i++)
        {
            if((a[i] == a[i+1]) || (a[i] == a[i+1]+1))
            {
                if(flag%2== 0)
                {
                    x = a[i+1];
                    flag++;
                    i++;
                }
                else if(flag%2== 1)
                {
                    pf = 1;
                    y = a[i+1];
                    ans += x * y;
                    flag++;
                    i++;
                }
            }
        }
        if(pf == 0)
        {
            printf("0\n");
        }
        else
        {
            printf("%I64d\n",ans);
        }
    }
    return 0;
}