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 contest::io::Scanner;
use contest::math::Mint;

fn main() {
    let mut sc = Scanner::new(std::io::stdin());
    let n = sc.next::<usize>();
    let x = sc.next::<usize>();
    let mut s: Vec<usize> = vec![];
    for _ in 0..n {
        s.push(sc.next());
    }
    s.sort();
    s.reverse();
    let mut dp = vec![Mint(0); x + 1];
    dp[x] = Mint(1);
    for i in 0..n {
        let mut ndp = vec![Mint(0); x + 1];
        for j in 0..(x + 1) {
            // Use
            ndp[j % s[i]] += dp[j];
            // Not use
            ndp[j] += dp[j] * Mint((n - 1 - i) as i64);
        }
        dp = ndp;
    }
    let mut res = Mint(0);
    for i in 0..(x + 1) {
        res += Mint(i as i64) * dp[i];
    }
    println!("{}", res);
}
pub mod contest {
    pub mod io {
        /// Scanner
        ///
        /// # Example
        /// ```
        /// use contest::io::Scanner;
        /// let mut sc = Scanner::new("1 2 \n\n \r\t \n 3.5".as_bytes());
        /// assert_eq!("1".to_string(), sc.next::<String>());
        /// assert_eq!(2, sc.next());
        /// assert_eq!(3.5, sc.next());
        ///
        /// // To create a scanner from stdin:
        /// Scanner::new(std::io::stdin());
        /// ```
        use std;
        use std::io;
        use std::io::BufRead;

        pub struct Scanner<R: io::Read> {
            br: io::BufReader<R>,
            // Read tokens are stored in reversed order per line.
            buf: Vec<String>,
        }

        pub fn new<R: io::Read>(r: R) -> Scanner<R> {
            Scanner::new(r)
        }

        impl<R: io::Read> Scanner<R> {
            #[inline]
            pub fn new(r: R) -> Scanner<R> {
                Scanner {
                    br: io::BufReader::new(r),
                    buf: vec![],
                }
            }
            #[inline]
            pub fn next<T>(&mut self) -> T
            where
                T: std::str::FromStr,
                T::Err: std::fmt::Debug,
            {
                self.next_string()
                    .map(|s| s.parse::<T>().expect("Parse failed: "))
                    .expect("Unexpected EOF")
            }
            #[inline]
            pub fn next2<T1, T2>(&mut self) -> (T1, T2)
            where
                T1: std::str::FromStr,
                T2: std::str::FromStr,
                T1::Err: std::fmt::Debug,
                T2::Err: std::fmt::Debug,
            {
                (self.next(), self.next())
            }
            fn next_string(&mut self) -> Option<String> {
                self.buf.pop().or_else(|| match self.update() {
                    true => self.next_string(),
                    false => None,
                })
            }
            #[inline]
            fn update(&mut self) -> bool {
                let mut s = String::new();
                let res = self.br.read_line(&mut s);
                match res.expect("I/O error.") {
                    0 => false,
                    _ => {
                        self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                        true
                    }
                }
            }
        }

        #[test]
        fn test_next() {
            let mut sc = new("hoge".as_bytes());
            let s: String = sc.next();
            assert_eq!("hoge", s);
        }
    }
    pub mod math {
        //! math library.

        use std::ops::Add;
        use std::ops::AddAssign;
        use std::ops::Div;
        use std::ops::DivAssign;
        use std::ops::Mul;
        use std::ops::MulAssign;
        use std::ops::Sub;
        use std::ops::SubAssign;

        static mut MODULO: i64 = 1_000_000_007;

        #[inline]
        fn modulo() -> i64 {
            unsafe { MODULO }
        }

        #[derive(Copy, Clone)]
        pub struct Mint(pub i64);

        impl Mint {
            pub fn set_mod(modulo: i32) {
                unsafe {
                    MODULO = modulo as i64;
                }
            }
            pub fn value(self) -> i64 {
                self.0
            }
        }

        impl ::std::fmt::Display for Mint {
            fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
                write!(f, "{}", self.0)
            }
        }

        /// ```
        /// use contest::math::Mint;
        /// Mint::set_mod(5);
        /// assert_eq!(1, (Mint(2) + Mint(4)).0);
        /// ```
        impl Add for Mint {
            type Output = Mint;
            fn add(self, o: Mint) -> Mint {
                let mut x = self.0 + o.0;
                if x >= modulo() {
                    x -= modulo();
                }
                Mint(x)
            }
        }

        /// ```
        /// use contest::math::Mint;
        /// Mint::set_mod(5);
        /// let mut a = Mint(2);
        /// a += Mint(4);
        /// assert_eq!(1, a.0);
        /// ```
        impl AddAssign for Mint {
            fn add_assign(&mut self, o: Mint) {
                let mut x = self.0 + o.0;
                if x >= modulo() {
                    x -= modulo();
                }
                self.0 = x;
            }
        }

        /// ```
        /// use contest::math::Mint;
        /// Mint::set_mod(5);
        /// assert_eq!(4, (Mint(2) - Mint(3)).0);
        /// ```
        impl Sub for Mint {
            type Output = Mint;
            fn sub(self, o: Mint) -> Mint {
                let mut x = self.0 - o.0;
                if x < 0 {
                    x += modulo();
                }
                Mint(x)
            }
        }

        /// ```
        /// use contest::math::Mint;
        /// Mint::set_mod(5);
        /// let mut a = Mint(2);
        /// a -= Mint(4);
        /// assert_eq!(3, a.0);
        /// ```
        impl SubAssign for Mint {
            fn sub_assign(&mut self, o: Mint) {
                let mut x = self.0 - o.0;
                if x < modulo() {
                    x += modulo();
                }
                self.0 = x;
            }
        }

        /// ```
        /// use contest::math::Mint;
        /// Mint::set_mod(5);
        /// assert_eq!(1, (Mint(2) * Mint(3)).0);
        /// ```
        impl Mul for Mint {
            type Output = Mint;
            fn mul(self, o: Mint) -> Mint {
                let x = (self.0 * o.0) % modulo();
                Mint(x)
            }
        }

        /// ```
        /// use contest::math::Mint;
        /// Mint::set_mod(5);
        /// let mut a = Mint(2);
        /// a *= Mint(4);
        /// assert_eq!(3, a.0);
        /// ```
        impl MulAssign for Mint {
            fn mul_assign(&mut self, o: Mint) {
                let x = (self.0 * o.0) % modulo();
                self.0 = x;
            }
        }

        /// ```
        /// use contest::math::Mint;
        /// Mint::set_mod(5);
        /// assert_eq!(4, (Mint(2) / Mint(3)).0);
        /// ```
        impl Div for Mint {
            type Output = Mint;
            fn div(self, o: Mint) -> Mint {
                let x = self.0 * inv(o.0, modulo()) % modulo();
                Mint(x)
            }
        }

        /// ```
        /// use contest::math::Mint;
        /// Mint::set_mod(5);
        /// let mut a = Mint(2);
        /// a /= Mint(4);
        /// assert_eq!(3, a.0);
        /// ```
        impl DivAssign for Mint {
            fn div_assign(&mut self, o: Mint) {
                let x = self.0 * inv(o.0, modulo()) % modulo();
                self.0 = x;
            }
        }

        /// ```
        /// use contest::math;
        /// assert_eq!(3, math::inv(2,5));
        /// assert_eq!(1, math::inv(1,2));
        /// assert_eq!(1, math::inv(3,2));
        /// ```
        pub fn inv(value: i64, modulo_prime: i64) -> i64 {
            return pow_mod(value, modulo_prime - 2, modulo_prime);
        }

        /// ```
        /// use contest::math;
        /// assert_eq!(8, math::pow_mod(2,3,10));
        /// assert_eq!(1, math::pow_mod(3,4,10));
        /// assert_eq!(1, math::pow_mod(0,0,3));
        /// assert_eq!(0, math::pow_mod(0,0,1));
        /// ```
        pub fn pow_mod(value: i64, exponent: i64, modulo: i64) -> i64 {
            if exponent < 0 {
                panic!("Exponent should >= 0.");
            }
            if modulo == 1 {
                return 0;
            }
            let modulo = modulo;
            let mut value = value;
            if value >= modulo {
                value %= modulo;
            }
            if value < 0 {
                value = value % modulo + value;
            }
            let mut res = 1;
            let mut exponent = exponent;
            while exponent > 0 {
                if (exponent & 1) == 1 {
                    res = res * value % modulo;
                }
                value = value * value % modulo;
                exponent >>= 1;
            }
            res
        }
    }
}