let _ = readLine()
let A = readLine()!.characters.split(" ").map{Int(String($0))!}
var dic = [Int : Int]()
for i in A {
    if dic[i] == nil {
        dic[i] = 0
    }
    dic[i]! += 1
}
let a = dic.filter{$0.1>=2}.sort(){$0.0>$1.0}
var ans = 0
if a.count > 0 {
    if a[0].1 >= 4 {
        ans = a[0].0 * a[0].0
    } else if a[1].1 >= 2 {
        ans = a[0].0 * a[1].0
    }
}
print(ans)