import collections

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

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


f = collections.Counter(cum)
ans = 0
for i in f:
    ans += f[i]*(f[i]-1)//2
print(ans)