import sequtils, strutils, algorithm, math, sets, tables
when (NimMajor,NimMinor) <= (0,18): import future else: import sugar
proc scanf(fmt: cstring){.header: "<stdio.h>", varargs.}
proc scan():int=scanf("%lld",addr result)
template `MIN=`(a,b:untyped)=a=min(a,b)
template `MAX=`(a,b:untyped)=a=max(a,b)
template SEQ2D(y,x:int,p:untyped):untyped=newSeqWith(y,newSeqWith(x,p))

let N,M = scan()
var A = newSeqWith(N,scan())

var wa = newSeqWith(N+1,0)
for i in 0..<N:
  wa[i+1] = A[i]+wa[i]

var ans = 0
for j in 0..<N:
  for i in j..<N:
    if ((wa[i+1]-wa[j])mod M) == 0: ans += 1

echo ans
