{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

import Data.STRef
import qualified Data.Map.Strict as M

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, m ] <- readInts
	as <- map ( `mod` m ) . scanl (+) 0 <$> readInts
	print $ solve m as

solve m as = solve' M.empty m as
	where
		solve' _ _ [] = 0
		solve' counts m (a:as) = res + solve' counts' m as
			where
				res = M.findWithDefault 0 (a `mod` m ) counts
				counts' = M.insertWith (+) a 1 counts