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;

public class Hello{
    public static Scanner sc = new Scanner();
    public static void Main(){
        var n = sc.NextInt();
        var list = sc.NextIntList()
            .GroupBy(i => i)
            .Where(i => 2 <= i.Count());
            
        if(list.Count() < 2){
            Console.WriteLine(0);
        } else {
            var l = list.OrderBy(i => -i.Key).ToList();
            Console.WriteLine(l[0].Key * l[1].Key);    
        }
    }
    

    public static bool Solved(List<int> list){
        for(var i = 0; i < list.Count; ++i){
            if(list[i] == i + 1) return false;
        }
        return true;
    }
    
    public static IEnumerable<int> Swap(List<int> list, int i){
        for(var j = 0; j < list.Count; ++j){
            if(j == i) {
                yield return list[i + 1];
            } else if(j - 1 == i) {
                yield return list[i];
            } else {
                yield return list[j];
            }
        }
    }
}

public class Scanner{
    private string line;
    private string[] token;
    private int cursole = 0;
    
    public string ReadLine(){
        line = Console.ReadLine();
        token = line.Split(' ');
        cursole = 0;
        return line;    
    }
    
    public string Next(){
        if(token == null) ReadLine();
        if(token.Length <= cursole) ReadLine();
        var ret = token[cursole];
        ++cursole;
        return ret;
    }

    public IEnumerable<double> NextDoubleList(){
        return NextList().Select(s => Double.Parse(s));
    }

    public int NextInt(){return Int32.Parse(Next());}
    
    public long NextLong(){return Int64.Parse(Next());}

    public double NextDouble(){return Double.Parse(Next());}

    public IEnumerable<string> NextList(){
        ReadLine();
        cursole = Int32.MaxValue;
        return token;
    }
    
    public IEnumerable<int> NextIntList(){
        return NextList().Select(s => Int32.Parse(s));
    }
}

public static class Extension{
    public static IEnumerable<int> To(this int from, int to){
        return Enumerable.Range(from, to);
    }

    public static void Times(this int times, Action<int> action){
        0.To(times).ToList().ForEach(x => action(x));
    }
}