n,m=map(int,input().split())
a=list(map(int,input().split()))
s=[0]
for i in a:
    s.append((s[-1]+i)%m)
r = 0
for i in range(n-1):
    for j in range(i+1,n+1):
        if (s[i]-s[j])%m==0:
            r += 1
print(r)
