from itertools import*
from collections import*
n,m,*a=map(int,open(0).read().split())
d=defaultdict(int)
for i in range(n):
    for j in accumulate(a[i:]):
        d[j]+=1
ans=0
for k,v in d.items():
    if k%m==0:
        ans+=v
print(ans)