import sequtils, strutils, algorithm, math

let
  nm = stdin.readline.split.map(parseInt)
  (n, m) = (nm[0], nm[1])
  bs = stdin.readline.split.map(parseInt)
var
  cnts = newSeq[int](n+1)

for i in 0..<n:
  var
    j = i+1
    acc = bs[i]
  while j<n and acc mod m != 0:
    acc += bs[j]
    inc j
  if acc mod m == 0:
    cnts[j] += cnts[i]+1

echo sum(cnts)
