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;

namespace _071
{
    class Program
    {
        static void Main(string[] args)
        {
            //
            ProblemC.Solve();
        }
    }

    class ProblemB
    {
        public static void Solve()
        {
            string S = Console.ReadLine();

            HashSet<char> alpha = new HashSet<char>()
            {
                'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
            };

            foreach (char item in S)
            {
                if (alpha.Contains(item))
                {
                    alpha.Remove(item);
                }
            }

            if (alpha.Count < 1)
            {
                Console.WriteLine("None");
            }
            else
            {
                Console.WriteLine(alpha.ToList().OrderBy(x=>x).First());
            }
        }
    }

    class ProblemC
    {
        public static void Solve()
        {
            string N = Console.ReadLine();

            long[] Aarr = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            Aarr = Aarr.OrderByDescending(x => x).ToArray();

            for (int i = 0; i <= Aarr.Length-4; i++)
            {
                long a = Aarr[i];
                long b = Aarr[i+1];
                long c = Aarr[i+2];
                long d = Aarr[i+3];

                if (IsRectangle(a, b, c, d))
                {
                    Console.WriteLine(a * c);
                    return;
                }
            }

            Console.WriteLine(0);
            return;


        }

        static bool IsRectangle(long a, long b, long c, long d)
        {
            if (a == b && a == c && a == d)
            {
                return true;
            }

            IDictionary<long, int> dic = new Dictionary<long, int>() { [a] = 0, [b] = 0, [c] = 0, [d] = 0};
            dic[a]++;
            dic[b]++;
            dic[c]++;
            dic[d]++;

            if (dic.Keys.Count == 2 && dic[dic.Keys.First()] == 2)
            {
                return true;
            }

            return false;
        }
    }
}