let sum bitree index =
  let rec loop sum i =
    if i > 0 then loop (sum+bitree.(i)) (i land (-i) |> (-) i)
    else sum
  in loop 0 index

let update bitree n index v =
  let rec loop i =
    if i <= n then (bitree.(i) <- bitree.(i) + v;
                    loop (i land (-i) |> (+) i))
  in loop index

let count arr n =
  let maxv = Array.fold_left (fun acc x -> max acc x) min_int arr in
  let bitree = Array.make (maxv+1) 0 in
  let cnt = ref 0 in
  for i = n - 1 downto 0 do
    cnt := sum bitree (arr.(i)-1) |> (+) !cnt;
    update bitree maxv arr.(i) 1
  done;
  !cnt

let () =
  let n = read_int () in
  let arr = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  count arr n |> Printf.printf "%d\n"