open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then Enum.empty ()
  else
    List.map (fun _ -> scan fmt f) (List.range 1 `To n)
    |> List.enum

let scan_list cnv =
  String.split_on_char ' ' @@ read_line ()
  |> List.map cnv

let scan_array cnv = Array.of_list @@ scan_list cnv

let scan_matrix n m e conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (List.range 0 `To (pred n))
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let n = scan "%d" id
let a = scan_array Int.of_string
let b = scan_array Int.of_string
let c = scan_array Int.of_string


let () =
  Array.sort Int.compare a;
  Array.sort Int.compare b;
  Array.sort Int.compare c;
  let lena = Array.length a in
  let lenb = Array.length b in
  let lenc = Array.length c in
  let d = Array.of_list @@
    ListL.map (0 ++^ lenb) ~f:(fun i ->
        match Array.bsearch Int.ord c b.(i) with
        | `At i | `Just_after i -> lenc - (succ i)
        | `All_bigger -> lenc
        | _ -> 0) in
  ListL.iter (List.rev @@ 0 ++^ Array.length d) ~f:(fun i ->
      if i - 1 >= 0 then
        d.(i-1) <- d.(i-1) + d.(i));
  ListL.map (0 ++^ lena) ~f:(fun i ->
      match Array.bsearch Int.ord b a.(i) with
      | `At i | `Just_after i -> d.(succ i)
      | `All_bigger -> d.(0)
      | _ -> 0)
  |> List.sum
  |> Printf.printf "%d\n"
