import Data.List

main = do
  (_:m:_) <- getInts
  as <- getInts
  let sigma = scanl (+) 0 as
  print $ sum $ map (_C2.length) $ group.sort $ map (`mod` m) sigma
 where _C2 n = (n * (n-1)) `div` 2
       
getInts = map read.words <$> getLine :: IO [Int]