const p = (...args) => {
  process.env.NODE_ENV === "test" ? console.log(...args) : ""
}

const removeArr = (s, i) => {
  return s.filter((ss, ii) => i !== ii)
}

const fact = (n) => {
  return Array.from({ length: n })
    .map((_, i) => i + 1)
    .reduce((curr, i) => {
      return curr * i
    }, 1)
}

const getMods = (x, y, arr) => {
  // const mod = x % y
  if (arr.length == 0) {
    return x % y
  }
  const mod = x % y
  // console.log(mod, x, y, arr)
  return arr
    .map((yy, i) => {
      const narr = removeArr(arr, i)
      if (mod < yy && mod < narr[0]) {
        return mod * fact(narr.length)
      }
      return getMods(mod, yy, narr)
    })
    .reduce((a, b) => a + b, 0)
}

const solve = (input) => {
  const e = 10 ** 9 + 7
  const [head, line] = input.split("\n")
  const [_, x] = head.split(" ").map(Number)
  const s = line
    .split(" ")
    .map(Number)
    .sort((a, b) => a - b)
  const a = s
    .map((y, i) => {
      return getMods(x, y, removeArr(s, i))
    })
    .reduce((a, b) => a + b, 0)
  return a % e
}

if (process.env.NODE_ENV === "test") {
  module.exports = (input) => solve(input.trim())
} else {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(solve(input.trim()))
}
