let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( *^ ) x y = (x * y) mod m

let memoize n f =
  let dp = Hashtbl.create n in
  let rec get x =
    try Hashtbl.find dp x with
    | Not_found ->
        let result = f get x in
        Hashtbl.add dp x result;
        result in
  get

let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let inv n = power ( *^ ) 1 n (m - 2)
let perm n k =
  Array.fold_left ( *^ ) 1 @@
  Array.init k @@ ( +^ ) (n - k + 1)
let comb n k = power ( *^ ) (perm n k) (perm k k) (m - 2)
let repcomb n k = comb (n + k - 1) k

let () = Scanf.scanf "%d %d\n" @@ fun n x ->
  let ss = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun s -> s in
  Array.sort compare ss;
  let dp = memoize (n * n * n) @@ fun dp (i, x) ->
    if i = 0 then x
    else 
      Array.fold_left ( +^ ) 0 @@ Array.init i @@ fun j ->
        perm (i - 1) (i - j - 1) *^ dp (j, x mod ss.(j)) in
  Printf.printf "%d\n" @@ dp (n, x)
