n,m = map(int,input().split())
a = list(map(int,input().split()))
s = [0 for i in range(0,n+1)]
d = {0:1}
ans = 0
for i in range(0,len(a)):
    s[i+1] += a[i] + s[i]
    r = s[i+1]%m
    ans += d.get(r,0)
    d[r] = d.get(r,0) + 1
print(ans)
