N,M=map(int,input().split(" "))
A=list(map(int,input().split(" ")))

ans=0
for l in range(N):
    for r in range(N-l):
        B=0
        for i in range(r+1):
            B+=A[l+i]
        if B%M==0:
            ans+=1
print(ans)