n, m = [int(i) for i in input().split()]
a= [int(i)%m for i in input().split()]

s = [0]*(n+1)
for i in range(len(a)):
    s[i+1]=(s[i]+a[i])%m

ans= 0
for i in range(len(s)):
    ans += s[0:i].count(s[i])

print(ans)