import Control.Monad
import Data.List
import Data.Maybe
import Data.Bits

query :: Int -> [Int] -> Int
query m = sum . map ((\n -> (n * (n-1)) `div` 2) . length)
  . group . sort . scanl (\x y -> (x + y) `mod` m) 0 

main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine
  ais <- map read . words <$> getLine
  putStrLn $ show $ query m ais