Problem:
Score : 600 points

Problem Statement

Snuke has a blackboard and a set S consisting of N integers.
The i-th element in S is S_i.

He wrote an integer X on the blackboard, then performed the following operation N times:

Choose one element from S and remove it.

Let x be the number written on the blackboard now, and y be the integer removed from S. Replace the number on the blackboard with x \bmod {y}.

There are N! possible orders in which the elements are removed from S.
For each of them, find the number that would be written on the blackboard after the N operations, and compute the sum of all those N! numbers modulo 10^{9}+7.

Constraints

All values in input are integers.

1 \leq N \leq 200

1 \leq S_i, X \leq 10^{5}

S_i are pairwise distinct.

Input

Input is given from Standard Input in the following format:

N X
S_1 S_2 \ldots S_{N}

Output

Print the answer.

Sample Input 1

2 19
3 7

Sample Output 1

3

There are two possible orders in which we remove the numbers from S.

If we remove 3 and 7 in this order, the number on the blackboard changes as follows: 19 \rightarrow 1 \rightarrow 1.

If we remove 7 and 3 in this order, the number on the blackboard changes as follows: 19 \rightarrow 5 \rightarrow 2.

The output should be the sum of these: 3.

Sample Input 2

5 82
22 11 6 5 13

Sample Output 2

288

Sample Input 3

10 100000
50000 50001 50002 50003 50004 50005 50006 50007 50008 50009

Sample Output 3

279669259

Be sure to compute the sum modulo 10^{9}+7.

Solution in Rust (1.15.1) (judge verdict: Accepted)

use std::io::{self,Read};
use std::str::Chars;
use std::iter::FromIterator;

struct Source<'a> { chars: Chars<'a> }

#[allow(dead_code)]
impl<'a> Source<'a> {
    fn next_chr(&mut self) -> char {
        self.chars.by_ref()
            .skip_while(|c| char::is_whitespace(*c))
            .next()
            .expect("eof")
    }

    fn next_str(&mut self) -> String {
        let it = self.chars.by_ref()
            .skip_while(|c| char::is_whitespace(*c))
            .take_while(|c| !char::is_whitespace(*c));
        let s = String::from_iter(it);
        if s.len() == 0 {
            panic!("eof")
        } else {
            s
        }
    }
}

#[allow(unused_macros)]
macro_rules! input {
    (src = $str:expr; $($elem:tt)*) => {
        let mut src = Source {
            chars: $str.chars(),
        };

        input_inner!(src, $($elem)*)
    };
    ($($elem:tt)*) => {
        let mut data = String::new();
        io::stdin().read_to_string(&mut data).expect("Input error");
        let mut src = Source {
            chars: data.chars(),
        };

        input_inner!(src, $($elem)*)
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($src:expr) => {};
    ($src:expr,) => {};
    ($src:expr, $var:ident : mut $ty:tt $($rest:tt)*) => {
        let mut $var = parse!($src, $ty);
        input_inner!($src $($rest)*)
    };
    ($src:expr, $var:ident : $ty:tt $($rest:tt)*) => {
        let $var = parse!($src, $ty);
        input_inner!($src $($rest)*)
    };
}

#[allow(unused_macros)]
macro_rules! parse {
    ($src:expr, ( $($ty:tt),* )) => {
        ( $(parse!($src,$ty)),* )
    };
    ($src:expr, char) => {
        $src.next_chr()
    };
    ($src:expr, [ $ty:tt; $len:expr ]) => {
        (0..$len).map(|_| parse!($src,$ty)).collect::<Vec<_>>()
    };
    ($src:expr, $ty:tt) => {
        parse_str!($src,$ty)
    };
}

#[allow(unused_macros)]
macro_rules! parse_str {
    ($src:expr, chars) => {
        $src.next_str().chars().collect::<Vec<char>>()
    };
    ($src:expr, $ty:ty) => {
        $src.next_str().parse::<$ty>().expect("Parse error")
    };
}

const MOD: i64 = 1000_000_007;

fn mod_pow(a: i64, b: i64) -> i64 {
    if b == 0 {
        1
    } else {
        mod_pow(a*a%MOD,b/2) * if b & 1 == 1 { a } else { 1 } % MOD
    }
}

fn f(i: usize, s: &Vec<i32>, x:i32, dp: &mut Vec<Vec<i64>>) -> i64 {
    if i >= s.len() {
        x as i64
    } else {
        let n = s.len() as i64;
        if dp[i][x as usize] < 0 {
            let res = (f(i+1,s,x,dp)*(n-i as i64-1)%MOD + f(i+1,s,x%s[i],dp)) % MOD;
            dp[i][x as usize] = res * mod_pow(n-i as i64, MOD-2) % MOD;
        }

        dp[i][x as usize]
    }
}

fn main() {
    input! {
        n: usize, x: i32, s: mut [i32; n]
    }

    s.sort_by(|a, b| b.partial_cmp(a).unwrap());

    let mut dp: Vec<Vec<i64>> = vec![vec![-1; x as usize+1]; n];
    let mut res = f(0,&s,x,&mut dp);

    for i in 1..n+1 {
        res = res * i as i64 % MOD;
    }

    println!("{}", res);
}