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

s = []
k = 0
for i in range(0,n):
    k += a[i]
    s.append(k)

for i in range(0,n):
    s[i] = s[i]%m

d = [0]
ass = 0
w = s.count(0)
ass += w*(w+1)//2

for i in range(0,n):
    if s[i] not in d:
        d.append(s[i])
        w = s.count(s[i])
        if w != 1:
            ass += w*(w-1)//2

print(ass)