module Main where

import           Control.Monad
import           Data.List
import           Data.List.Split
import           Data.Array.IO
import qualified Data.Vector as V

main :: IO ()
main = do
  [_, x] <- map read . words <$> getLine :: IO [Int]
  is <- permutations . map read . words <$> getLine :: IO [[Int]]
  let as = sum $ map (foldl mod x) is
  print (as `mod` 1000000007)