n, m = map(int, input().split())
a = list(map(int, input().split()))

ans = 0

l = [0]*(n+1)

for i in range(n):
    l[i+1] = (a[i]+l[i])%m

b = [0]*m

for i in range(n+1):
    b[l[i]]+=1

for i in range(m):
    if b[i] >1:
        ans += sum(range(1,b[i]))

print(ans)