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 Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D_ModuloOperations solver = new D_ModuloOperations();
        solver.solve(1, in, out);
        out.close();
    }

    static class D_ModuloOperations {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            final int MOD = (int) (1e9 + 7);
            int n = in.nextInt();
            int x = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            Arrays.sort(a);

            int[][] d = new int[n + 1][x + 1];
            for (int v = 0; v <= x; v++) {
                d[0][v] = v;
            }

//		int[][] C = new int[n + 1][n + 1];
//		C[0][0] = 1;
//		for (int i = 1; i < C.length; i++) {
//			C[i][0] = 1;
//			for (int j = 1; j < C.length; j++) {
//				C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
//			}
//		}
//		int[] fact = new int[n + 1];
//		fact[0] = 1;
//		for (int i = 1; i < fact.length; i++) {
//			fact[i] = (int)((long)i * fact[i - 1] % MOD);
//		}
//		boolean[] reachable = new boolean[x + 1];
//		reachable[x] = true;
//		int[] q = new int[x + 1];
//		int qt = 0;
//		int qh = 1;
//		q[0] = x;
//		while (qt < qh) {
//		    int v = q[qt++];
//		    for (int i = 0; i < n; i++) {
//		        int nv = v % a[i];
//		        if (!reachable[nv]) {
//		            reachable[nv] = true;
//		            q[qh++] = nv;
//                }
//            }
//        }
//        System.out.println("reachable " + qh);
//		for (int j = 0; j <= n; j++) {
//			for (int v = 0; v <= x; v++) {
//			    if (!reachable[v]) {
//			        continue;
//                }
//				for (int i = j + 1; i <= n; i++) {
//					int nv = v % a[j];
//					d[i][v] = (int)((d[i][v] + (long)C[i - 1][i - j - 1] * fact[i - j - 1] % MOD * d[j][nv]) % MOD);
//				}
//			}
//		}

            for (int i = 1; i <= n; i++) {
                for (int v = 0; v <= x; v++) {
                    d[i][v] += d[i - 1][v % a[i - 1]];
                    d[i][v] %= MOD;
                    d[i][v] += (long) d[i - 1][v] * (i - 1) % MOD;
                    d[i][v] %= MOD;
                }
            }

            out.println(d[n][x]);
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}