from collections import Counter
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = [0]
for i in range(len(a)):
    b.append((b[i]+a[i])%m)
ans = 0
for i in Counter(b).values():
    ans+=i*(i-1)//2
print(ans)