Problem:
Score : 300 points

Problem Statement

We have N sticks with negligible thickness.
The length of the i-th stick is A_i.

Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.
Find the maximum possible area of the rectangle.

Constraints

4 \leq N \leq 10^5

1 \leq A_i \leq 10^9

A_i is an integer.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print the maximum possible area of the rectangle.
If no rectangle can be formed, print 0.

Sample Input 1

6
3 1 2 4 2 1

Sample Output 1

2

1 \times 2 rectangle can be formed.

Sample Input 2

4
1 2 3 4

Sample Output 2

0

No rectangle can be formed.

Sample Input 3

10
3 3 3 3 4 4 4 5 5 5

Sample Output 3

20

Solution in C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class MakeARectangle
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine()); // 扱うデータの個数
        var stick = Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray();

        ulong largest = 0, larger = 0;
        var unique = new List<ulong>();

        foreach (var x in stick)
        {

            if (larger < x)
            {
                if (unique.Contains(x))
                {
                    
                    larger = x;
                    if (largest < larger)
                    {
                        larger ^= largest;
                        largest ^= larger;
                        larger ^= largest;
                    }

                    //unique.Find(z => z == larger);
                    unique.Remove(larger);
                }
                else
                {
                    unique.Add(x);
                }
            }

        }

        Console.WriteLine($"{larger},{largest}");
        Console.WriteLine($"{ umulh(larger, largest).ToString("#") }{larger * largest}");

    }

    // ulongの積の上位64bitを取得
    // 参考 (http://d.hatena.ne.jp/n7shi/20100630/1277983197)
    static public ulong umulh(ulong x, ulong y)
    {
        ulong xh = x >> 32, xl = x & 0xffffffff;
        ulong yh = y >> 32, yl = y & 0xffffffff;
        ulong a = xh * yl, ah = a >> 32, al = a & 0xffffffff;
        ulong b = xl * yh, bh = b >> 32, bl = b & 0xffffffff;
        return ((((xl * yl) >> 32) + al + bl) >> 32) + ah + bh + xh * yh;
    }
}