import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed as VU

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n, k] <- getIntList
    as <- getIntList
    let ls = VU.fromList $ scanl (+) 0 as
    let rs = VU.fromList $ scanr (+) 0 as
    let s = rs VU.! 0
    print $ length [() | i <- [1..n], j <- [0..n-i], (s - (ls VU.! j) - (rs VU.! (j+i))) `mod` k == i]