open Hashtbl
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let h = create n
let acs = Array.iter (fun a -> replace h a @@ try find h a + 1 with _ -> 1) a_s; List.(fold (fun a c xs -> (a, c) :: xs) h [] |> filter (fun (_, c) -> c >= 2) |> sort (fun x y -> compare y x))
let _ = Printf.printf "%d\n" @@ match acs with (a, c) :: (b, _) :: _ -> if c >= 4 then a * a else a * b | (a, c) :: _ -> if c >= 4 then a * a else 0 | _ -> 0