let solve a_arr =
    let a_lst = Array.groupBy id a_arr
                |> Array.sortBy (fun (k, v) -> -(Array.length v))
                |> Array.map (fun (k, v) -> v)
                |> Array.concat
                |> List.ofArray

    let rec solve' lst result =
        //eprintfn "%A %A" lst result

        match lst with
        | [] -> result
        | a :: b :: c :: rest ->
            let rest, result =
                if a <> b && b <> c then
                    c :: rest, a :: b :: result
                elif a = b && b = c then
                    b :: rest, result
                elif a <> b && rest <> [] then
                    b :: c :: rest, a :: result
                else
                    b :: rest, result
                    
            solve' rest result

        | a :: rest ->
            solve' rest (a :: result)

    solve' a_lst []
    |> List.length

let () =
    let _ = stdin.ReadLine()
    let a_arr = stdin.ReadLine().Split()
                |> Array.map int

    solve a_arr
    |> printfn "%d"
