local n=io.read("*n","*l")
local a={}
for i=1,n do
    local bar=io.read("*n")
    if not a[bar] then
        a[bar]=1
    else
        a[bar]=a[bar]+1
    end
end

local barmax=0
for length,number in pairs(a) do
    if number>1 then
        barmax=math.max(length,barmax)
    end
end
if barmax==0 then
    print(0)
end
if a[barmax]>=4 then
    print(barmax*barmax)
else
    local barmax2=0
    for length,number in pairs(a) do
        if length<barmax and number>1 then
            barmax2=math.max(length,barmax2)
        end
    end
    print(barmax*barmax2)
end