let rec expt ( * ) e a n = if n = 0 then e else if n land 1 = 1 then a * expt ( * ) e (a * a) (n / 2) else expt ( * ) e (a * a) (n / 2) let mod_expt a n mo = expt (fun x y -> x * y mod mo) 1 a n let mod_inv a p = mod_expt a (p - 2) p module Combination : sig type t val init : n:int -> modulo:int -> t val fact : int -> t -> int val inv_fact : int -> t -> int val nPk : int -> int -> t -> int val nCk : int -> int -> t -> int val nHk : int -> int -> t -> int end = struct type t = int * int array * int array let init ~n ~modulo = let f = Array.make (n + 1) 0 in let () = f.(0) <- 1; for i = 1 to n do f.(i) <- f.(i - 1) * i mod modulo done in let inv_f = Array.make (n + 1) 0 in let () = inv_f.(n) <- mod_inv f.(n) modulo; for i = n - 1 downto 0 do inv_f.(i) <- inv_f.(i + 1) * (i + 1) mod modulo done in (modulo, f, inv_f) let fact n (_, f, _) = f.(n) let inv_fact n (_, _, inv_f) = inv_f.(n) let nPk n k ((mo, _, _) as c) = if n < k then 0 else fact n c * inv_fact (n - k) c mod mo let nCk n k ((mo, _, _) as c) = if n < k then 0 else fact n c * inv_fact k c mod mo * inv_fact (n - k) c mod mo let nHk n k c = if n = 0 && k = 0 then 1 else nCk (n + k - 1) k c end let id x = x let mo = 1_000_000_007 let c = Combination.init ~n:200100 ~modulo:mo let (n, m, p) = Scanf.scanf "%d %d %d" (fun n m p -> (n, m, p)) let (p, q) = (p * mod_inv 100 mo mod mo, (100 - p) * mod_inv 100 mo mod mo) let v = Array.init n (fun _ -> Scanf.scanf " %d" id) let () = Array.sort (fun x y -> - compare x y) v; for i = 1 to n - 1 do v.(i) <- v.(i) + v.(i - 1) done let cnt = ref 0 let () = for i = 1 to n - 1 do (* i 匹目まで掬うことができた *) let prob = Combination.nHk (i + 1) (m - 1) c mod mo * mod_expt p m mo mod mo * mod_expt q i mo mod mo in cnt := (!cnt + v.(i - 1) * prob mod mo) mod mo done; for j = 0 to m - 1 do (* N 匹目まで掬うことができた.破れたポイは j 個 *) let prob = Combination.nHk n j c mod mo * mod_expt p j mo mod mo * mod_expt q n mo mod mo in cnt := (!cnt + v.(n - 1) * prob mod mo) mod mo done; print_int !cnt; print_newline ()