import Data.List

main = do
  (n:m:_) <- getInts
  as <- getInts
  let seqs = filter (/= []) $ concat $ take n $ iterate (\xs -> map tail $ tail xs) $ inits as
  print $ length $ filter (\xs -> sum xs `mod` m == 0) $ seqs
 where getInts = map read.words <$> getLine
