import Data.List
import Data.Array
import Data.Array.IO
import Data.Maybe
import Data.Bits
import Control.Monad
import Control.Applicative

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

listToTuple2 (a:b:_) = (a,b)
listToTuple3 (a:b:c:_) = (a,b,c)
listToTuple4 (a:b:c:d:_) = (a,b,c,d)

main :: IO ()
main = do
  (n:m:_) <- getLine >>= return . map read . words :: IO [Int]
  as <- getLine >>= return . map read . words :: IO [Int]

  let
    solve [] = 0
    solve (x:xs) = (length $ filter (\y -> mod (y-x) m == 0) xs) + solve xs

  print $ solve (scanl (+) 0 as)

  return ()
